<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2018-12-16
 * Time: 13:55
 */

namespace app\common\lib\horoscope;

use app\common\lib\astrolog\Astrolog;
use app\common\model\SolarTerms;
use Overtrue\ChineseCalendar\Calendar;
use think\Exception;
use think\Log;

/**
 * 八字类库
 * Class HoroscopeData
 * @package app\common\lib\astrolog
 */
class Horoscope
{
    public static $_instance;
    /**
     * 八字相关的参数信息
     * @var array
     * time_type int 时间类型 [0=>北京时间,1=>真太阳时]
     * time_start int 日辰初始 [0 => 24点,23=>子时]
     * recode array 用户的档案信息
     *  id 档案id
     *  uid 用户id
     *  name 用户档案名称
     *  type 用户性别/类别 [1=>男,2=>女]
     *  year 出生日期-年
     *  month 出生日期-月 1~12
     *  day 出生日期-日 1~
     *  hour 出生日期-小时 0~23
     *  minute 出生日期-分钟 0~59
     *  timezone 出生日期-时区 -12~12
     *  birth_country 出生地址-省
     *  birth_province 出生地址-市
     *  birth_city 出生地址-区
     *  live_country 现居地址-省
     *  live_province 现居地址-市
     *  live_city 现居地址-区
     *  comments 标签：自己，朋友，案例...
     *  isself 是否自己 [0=>否,1=>是自己的档案]
     *  long_deg 出生地-经度-度 0~180
     *  long_min 出生地-经度-分 0~59
     *  ew -1=>西经,1=>东经
     *  lat_deg 出生地-纬度-度 0~90
     *  lat_min 出生地-纬度-分 0~59
     *  ns -1=>南纬,1=>北纬
     *  avatar 档案头像
     *  status 档案状态 1=>正常
     *  from 档案来源 zhunle=>app内添加的档案
     *  is_summer 是否为夏令时
     *  aid 档案的行星信息 链表字段
     * advance array
     *  year 需要计算的年份
     */
    public $option = [
        'time_type' => 1, // 0 => 北京时间, 1 => 真太阳时
        'time_start' => 23,
        'recode' => [],
        'advance' => [],
        'shensha' => 2,// 神煞 0=>不显示 1=>精简版 2=>详细
        'liuyue' => 1, // 流月设置 0=>不显示流月 1=>显示流月
        'liunian_realtime' => false,
    ];
    /**
     * @var array
     * chinese_era 六十甲子
     * heavenly_stems 十天干
     * earthly_branches 十二地支
     * wuxing 天干的五行属性
     * wuxing_yinyang 五行阴阳
     * shishen 十神对照表
     * canggan 地支藏干表
     * shensha 神煞对照表
     * changsheng 长生十二宫对照表
     */
    public $param = [
        'chinese_era' => [
            0 => '甲子',
            1 => '乙丑',
            2 => '丙寅',
            3 => '丁卯',
            4 => '戊辰',
            5 => '己巳',
            6 => '庚午',
            7 => '辛未',
            8 => '壬申',
            9 => '癸酉',
            10 => '甲戌',
            11 => '乙亥',
            12 => '丙子',
            13 => '丁丑',
            14 => '戊寅',
            15 => '己卯',
            16 => '庚辰',
            17 => '辛巳',
            18 => '壬午',
            19 => '癸未',
            20 => '甲申',
            21 => '乙酉',
            22 => '丙戌',
            23 => '丁亥',
            24 => '戊子',
            25 => '己丑',
            26 => '庚寅',
            27 => '辛卯',
            28 => '壬辰',
            29 => '癸巳',
            30 => '甲午',
            31 => '乙未',
            32 => '丙申',
            33 => '丁酉',
            34 => '戊戌',
            35 => '己亥',
            36 => '庚子',
            37 => '辛丑',
            38 => '壬寅',
            39 => '癸卯',
            40 => '甲辰',
            41 => '乙巳',
            42 => '丙午',
            43 => '丁未',
            44 => '戊申',
            45 => '己酉',
            46 => '庚戌',
            47 => '辛亥',
            48 => '壬子',
            49 => '癸丑',
            50 => '甲寅',
            51 => '乙卯',
            52 => '丙辰',
            53 => '丁巳',
            54 => '戊午',
            55 => '己未',
            56 => '庚申',
            57 => '辛酉',
            58 => '壬戌',
            59 => '癸亥',
        ],
        'heavenly_stems' => ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'],
        'earthly_branches' => ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'],
        'wuxing' => [
            '甲' => '木',
            '乙' => '木',
            '丙' => '火',
            '丁' => '火',
            '戊' => '土',
            '己' => '土',
            '庚' => '金',
            '辛' => '金',
            '壬' => '水',
            '癸' => '水',
        ],
        'wuxing_yinyang' => [
            '甲' => 0,
            '乙' => 1,
            '丙' => 0,
            '丁' => 1,
            '戊' => 0,
            '己' => 1,
            '庚' => 0,
            '辛' => 1,
            '壬' => 0,
            '癸' => 1,
        ],
        'shishen' => [
            '甲' => [
                '甲' => '比肩',
                '乙' => '劫财',
                '丙' => '偏印',
                '丁' => '正印',
                '戊' => '七杀',
                '己' => '正官',
                '庚' => '偏财',
                '辛' => '正财',
                '壬' => '食神',
                '癸' => '伤官',
            ],
            '乙' => [
                '甲' => '劫财',
                '乙' => '比肩',
                '丙' => '正印',
                '丁' => '偏印',
                '戊' => '正官',
                '己' => '七杀',
                '庚' => '正财',
                '辛' => '偏财',
                '壬' => '伤官',
                '癸' => '食神',
            ],
            '丙' => [
                '甲' => '食神',
                '乙' => '伤官',
                '丙' => '比肩',
                '丁' => '劫财',
                '戊' => '偏印',
                '己' => '正印',
                '庚' => '七杀',
                '辛' => '正官',
                '壬' => '偏财',
                '癸' => '正财',
            ],
            '丁' => [
                '甲' => '伤官',
                '乙' => '食神',
                '丙' => '劫财',
                '丁' => '比肩',
                '戊' => '正印',
                '己' => '偏印',
                '庚' => '正官',
                '辛' => '七杀',
                '壬' => '正财',
                '癸' => '偏财',
            ],
            '戊' => [
                '甲' => '偏财',
                '乙' => '正财',
                '丙' => '食神',
                '丁' => '伤官',
                '戊' => '比肩',
                '己' => '劫财',
                '庚' => '偏印',
                '辛' => '正印',
                '壬' => '七杀',
                '癸' => '正官',
            ],
            '己' => [
                '甲' => '正财',
                '乙' => '偏财',
                '丙' => '伤官',
                '丁' => '食神',
                '戊' => '劫财',
                '己' => '比肩',
                '庚' => '正印',
                '辛' => '偏印',
                '壬' => '正官',
                '癸' => '七杀',
            ],
            '庚' => [
                '甲' => '七杀',
                '乙' => '正官',
                '丙' => '偏财',
                '丁' => '正财',
                '戊' => '食神',
                '己' => '伤官',
                '庚' => '比肩',
                '辛' => '劫财',
                '壬' => '偏印',
                '癸' => '正印',
            ],
            '辛' => [
                '甲' => '正官',
                '乙' => '七杀',
                '丙' => '正财',
                '丁' => '偏财',
                '戊' => '伤官',
                '己' => '食神',
                '庚' => '劫财',
                '辛' => '比肩',
                '壬' => '正印',
                '癸' => '偏印',
            ],
            '壬' => [
                '甲' => '偏印',
                '乙' => '正印',
                '丙' => '七杀',
                '丁' => '正官',
                '戊' => '偏财',
                '己' => '正财',
                '庚' => '食神',
                '辛' => '伤官',
                '壬' => '比肩',
                '癸' => '劫财',
            ],
            '癸' => [
                '甲' => '正印',
                '乙' => '偏印',
                '丙' => '正官',
                '丁' => '七杀',
                '戊' => '正财',
                '己' => '偏财',
                '庚' => '伤官',
                '辛' => '食神',
                '壬' => '劫财',
                '癸' => '比肩',
            ],
        ],
        'canggan' => [
            '亥' => ['壬', '甲'],
            '子' => ['癸'],
            '丑' => ['己', '癸', '辛'],
            '寅' => ['甲', '丙', '戊'],
            '卯' => ['乙'],
            '辰' => ['戊', '乙', '癸'],
            '巳' => ['丙', '戊', '庚'],
            '午' => ['丁', '己',],
            '未' => ['己', '丁', '乙'],
            '申' => ['庚', '壬', '戊'],
            '酉' => ['辛'],
            '戌' => ['戊', '辛', '丁'],
        ],
        'shensha' => [
            '华盖' => [
                '寅' => '戌',
                '午' => '戌',
                '戌' => '戌',
                '亥' => '未',
                '卯' => '未',
                '未' => '未',
                '申' => '辰',
                '子' => '辰',
                '辰' => '辰',
                '巳' => '丑',
                '酉' => '丑',
                '丑' => '丑',
            ],
            '桃花' => [
                '寅' => '卯',
                '午' => '卯',
                '戌' => '卯',
                '亥' => '子',
                '卯' => '子',
                '未' => '子',
                '申' => '酉',
                '子' => '酉',
                '辰' => '酉',
                '巳' => '午',
                '酉' => '午',
                '丑' => '午',
            ],
            '驿马' => [
                '寅' => '申',
                '午' => '申',
                '戌' => '申',
                '亥' => '巳',
                '卯' => '巳',
                '未' => '巳',
                '申' => '寅',
                '子' => '寅',
                '辰' => '寅',
                '巳' => '亥',
                '酉' => '亥',
                '丑' => '亥',
            ],
            '亡神' => [
                '寅' => '巳',
                '午' => '巳',
                '戌' => '巳',
                '亥' => '寅',
                '卯' => '寅',
                '未' => '寅',
                '申' => '亥',
                '子' => '亥',
                '辰' => '亥',
                '巳' => '申',
                '酉' => '申',
                '丑' => '申',
            ],
            '将星' => [
                '寅' => '午',
                '午' => '午',
                '戌' => '午',
                '亥' => '卯',
                '卯' => '卯',
                '未' => '卯',
                '申' => '子',
                '子' => '子',
                '辰' => '子',
                '巳' => '酉',
                '酉' => '酉',
                '丑' => '酉',
            ],
            '天乙贵人' => [
                '甲' => ['丑', '未'],
                '乙' => ['子', '申'],
                '丙' => ['酉', '亥'],
                '丁' => ['酉', '亥'],
                '戊' => ['丑', '未'],
                '己' => ['子', '申'],
                '庚' => ['丑', '未'],
                '辛' => ['寅', '午'],
                '壬' => ['巳', '卯'],
                '癸' => ['巳', '卯'],
            ],
            '天德贵人' => [
                '寅' => '丁',
                '卯' => '申',
                '辰' => '壬',
                '巳' => '辛',
                '午' => '亥',
                '未' => '甲',
                '申' => '癸',
                '酉' => '寅',
                '戌' => '丙',
                '亥' => '乙',
                '子' => '巳',
                '丑' => '庚',
            ],
            '文昌贵人' => [
                '甲' => '巳',
                '乙' => '午',
                '丙' => '申',
                '丁' => '酉',
                '戊' => '申',
                '己' => '酉',
                '庚' => '亥',
                '辛' => '子',
                '壬' => '寅',
                '癸' => '卯',
            ],
            '月德贵人' => [
                '申' => '壬',
                '子' => '壬',
                '辰' => '壬',
                '寅' => '丙',
                '午' => '丙',
                '戌' => '丙',
                '巳' => '庚',
                '酉' => '庚',
                '丑' => '庚',
                '亥' => '甲',
                '卯' => '甲',
                '未' => '甲',
            ],
            '金舆' => [
                '甲' => '辰',
                '乙' => '巳',
                '丙' => '未',
                '丁' => '申',
                '戊' => '未',
                '己' => '申',
                '庚' => '戌',
                '辛' => '亥',
                '壬' => '丑',
                '癸' => '寅',
            ],
            '红艳' => [
                '甲' => '午',
                '乙' => '申',
                '丙' => '寅',
                '丁' => '未',
                '戊' => '辰',
                '己' => '辰',
                '庚' => '申',
                '辛' => '酉',
                '壬' => '子',
                '癸' => '戌',
            ],
            '孤辰' => [
                '亥' => '寅',
                '子' => '寅',
                '丑' => '寅',
                '寅' => '巳',
                '卯' => '巳',
                '辰' => '巳',
                '巳' => '申',
                '午' => '申',
                '未' => '申',
                '申' => '亥',
                '酉' => '亥',
                '戌' => '亥',
            ],
            '寡宿' => [
                '亥' => '戌',
                '子' => '戌',
                '丑' => '戌',
                '寅' => '丑',
                '卯' => '丑',
                '辰' => '丑',
                '巳' => '辰',
                '午' => '辰',
                '未' => '辰',
                '申' => '未',
                '酉' => '未',
                '戌' => '未',
            ],
            '禄神' => [
                '甲' => '寅',
                '乙' => '卯',
                '丙' => '巳',
                '丁' => '午',
                '戊' => '巳',
                '己' => '午',
                '庚' => '申',
                '辛' => '酉',
                '壬' => '亥',
                '癸' => '子',
            ],
            '羊刃' => [
                '甲' => '卯',
                '乙' => '寅',// 辰
                '丙' => '午',
                '丁' => '巳',// 未
                '戊' => '午',
                '己' => '巳',// 未
                '庚' => '酉',
                '辛' => '申',// 戌
                '壬' => '子',
                '癸' => '亥',// 丑
            ],
            '金神' => [
                '癸酉', '己巳', '乙丑',
            ],
            '劫煞' => [
                '申' => '巳',
                '子' => '巳',
                '辰' => '巳',
                '寅' => '亥',
                '午' => '亥',
                '戌' => '亥',
                '巳' => '寅',
                '酉' => '寅',
                '丑' => '寅',
                '亥' => '申',
                '卯' => '申',
                '未' => '申',
            ],
            '魁罡' => [
                '戊戌', '庚戌', '庚辰', '壬辰',
            ],
            '灾煞' => [
                '申' => '午',
                '子' => '午',
                '辰' => '午',
                '寅' => '子',
                '午' => '子',
                '戌' => '子',
                '巳' => '卯',
                '酉' => '卯',
                '丑' => '卯',
                '亥' => '酉',
                '卯' => '酉',
                '未' => '酉',
            ],
            '词馆' => [
                '甲' => '庚寅',
                '乙' => '辛卯',
                '丙' => '乙巳',
                '丁' => '戊午',
                '戊' => '丁巳',
                '己' => '庚午',
                '庚' => '壬申',
                '辛' => '癸酉',
                '壬' => '癸亥',
                '癸' => '壬戌',
            ],
            '学堂' => [
                '金' => '巳',
                '木' => '亥',
                '水' => '申',
                '火' => '寅',
                '土' => '申',
            ],
            '国印' => [
                '甲' => '戌',
                '乙' => '亥',
                '丙' => '丑',
                '丁' => '寅',
                '戊' => '丑',
                '己' => '寅',
                '庚' => '辰',
                '辛' => '巳',
                '壬' => '未',
                '癸' => '申',
            ],
            '太极贵人' => [
                '甲' => ['子', '午'],
                '乙' => ['子', '午'],
                '丙' => ['酉', '卯'],
                '丁' => ['酉', '卯'],
                '戊' => ['辰', '戌', '丑', '未'],
                '己' => ['辰', '戌', '丑', '未'],
                '庚' => ['寅', '亥'],
                '辛' => ['寅', '亥'],
                '壬' => ['巳', '申'],
                '癸' => ['巳', '申'],
            ],
            '天德合' => [
                '亥' => '庚',
                '子' => '申',
                '丑' => '乙',
                '寅' => '壬',
                '卯' => '巳',
                '辰' => '丁',
                '巳' => '丙',
                '午' => '寅',
                '未' => '己',
                '申' => '戊',
                '酉' => '亥',
                '戌' => '辛',
            ],
            '月德合' => [
                '申' => '丁',
                '子' => '丁',
                '辰' => '丁',
                '寅' => '辛',
                '午' => '辛',
                '戌' => '辛',
                '巳' => '乙',
                '酉' => '乙',
                '丑' => '乙',
                '亥' => '己',
                '卯' => '己',
                '未' => '己',
            ],
            '德秀贵人' => [
                '申' => [['壬', '癸', '戊', '己'], ['丙', '辛', '甲', '乙']],
                '子' => [['壬', '癸', '戊', '己'], ['丙', '辛', '甲', '乙']],
                '辰' => [['壬', '癸', '戊', '己'], ['丙', '辛', '甲', '乙']],
                '寅' => [['丙', '丁'], ['戊', '癸']],
                '午' => [['丙', '丁'], ['戊', '癸']],
                '戌' => [['丙', '丁'], ['戊', '癸']],
                '巳' => [['庚', '辛'], ['乙', '庚']],
                '酉' => [['庚', '辛'], ['乙', '庚']],
                '丑' => [['庚', '辛'], ['乙', '庚']],
                '亥' => [['甲', '乙'], ['丁', '壬']],
                '卯' => [['甲', '乙'], ['丁', '壬']],
                '未' => [['甲', '乙'], ['丁', '壬']],
            ],
            '流霞' => [
                '甲' => '酉',
                '乙' => '戌',
                '丙' => '未',
                '丁' => '申',
                '戊' => '巳',
                '己' => '午',
                '庚' => '辰',
                '辛' => '卯',
                '壬' => '亥',
                '癸' => '寅',
            ],
            '元辰' => [
                // 阳男阴女
                [
                    '子' => '未',
                    '丑' => '申',
                    '寅' => '酉',
                    '卯' => '戌',
                    '辰' => '亥',
                    '巳' => '子',
                    '午' => '丑',
                    '未' => '寅',
                    '申' => '卯',
                    '酉' => '辰',
                    '戌' => '巳',
                    '亥' => '午',
                ],
                // 阴男阳女
                [
                    '子' => '巳',
                    '丑' => '午',
                    '寅' => '未',
                    '卯' => '申',
                    '辰' => '酉',
                    '巳' => '戌',
                    '午' => '亥',
                    '未' => '子',
                    '申' => '丑',
                    '酉' => '寅',
                    '戌' => '卯',
                    '亥' => '辰',
                ],
            ],
            '六厄' => [
                '申' => '卯',
                '子' => '卯',
                '辰' => '卯',
                '寅' => '酉',
                '午' => '酉',
                '戌' => '酉',
                '巳' => '午',
                '酉' => '午',
                '丑' => '午',
                '亥' => '子',
                '卯' => '子',
                '未' => '子',
            ],
            '天医' => [
                '亥' => '戌',
                '子' => '亥',
                '丑' => '子',
                '寅' => '丑',
                '卯' => '寅',
                '辰' => '卯',
                '巳' => '辰',
                '午' => '巳',
                '未' => '午',
                '申' => '未',
                '酉' => '申',
                '戌' => '酉',
            ],
            '五行正印' => [
                '金' => ['乙', '丑'],
                '木' => ['癸', '未'],
                '水' => ['壬', '辰'],
                '火' => ['甲', '戌'],
                '土' => ['丙', '辰'],
            ],
        ],
        'changsheng' => [
            '甲' => [
                '子' => '沐浴',
                '丑' => '冠带',
                '寅' => '临官',
                '卯' => '帝旺',
                '辰' => '衰',
                '巳' => '病',
                '午' => '死',
                '未' => '墓',
                '申' => '绝',
                '酉' => '胎',
                '戌' => '养',
                '亥' => '长生',
            ],
            '乙' => [
                '巳' => '沐浴',
                '辰' => '冠带',
                '卯' => '临官',
                '寅' => '帝旺',
                '丑' => '衰',
                '子' => '病',
                '亥' => '死',
                '戌' => '墓',
                '酉' => '绝',
                '申' => '胎',
                '未' => '养',
                '午' => '长生',
            ],
            '丙' => [
                '子' => '胎',
                '丑' => '养',
                '寅' => '长生',
                '卯' => '沐浴',
                '辰' => '冠带',
                '巳' => '临官',
                '午' => '帝旺',
                '未' => '衰',
                '申' => '病',
                '酉' => '死',
                '戌' => '墓',
                '亥' => '绝',
            ],
            '丁' => [
                '申' => '沐浴',
                '未' => '冠带',
                '午' => '临官',
                '巳' => '帝旺',
                '辰' => '衰',
                '卯' => '病',
                '寅' => '死',
                '丑' => '墓',
                '子' => '绝',
                '亥' => '胎',
                '戌' => '养',
                '酉' => '长生',
            ],
            '戊' => [
                '子' => '胎',
                '丑' => '养',
                '寅' => '长生',
                '卯' => '沐浴',
                '辰' => '冠带',
                '巳' => '临官',
                '午' => '帝旺',
                '未' => '衰',
                '申' => '病',
                '酉' => '死',
                '戌' => '墓',
                '亥' => '绝',
            ],
            '己' => [
                '申' => '沐浴',
                '未' => '冠带',
                '午' => '临官',
                '巳' => '帝旺',
                '辰' => '衰',
                '卯' => '病',
                '寅' => '死',
                '丑' => '墓',
                '子' => '绝',
                '亥' => '胎',
                '戌' => '养',
                '酉' => '长生',
            ],
            '庚' => [
                '午' => '沐浴',
                '未' => '冠带',
                '申' => '临官',
                '酉' => '帝旺',
                '戌' => '衰',
                '亥' => '病',
                '子' => '死',
                '丑' => '墓',
                '寅' => '绝',
                '卯' => '胎',
                '辰' => '养',
                '巳' => '长生',
            ],
            '辛' => [
                '亥' => '沐浴',
                '戌' => '冠带',
                '酉' => '临官',
                '申' => '帝旺',
                '未' => '衰',
                '午' => '病',
                '巳' => '死',
                '辰' => '墓',
                '卯' => '绝',
                '寅' => '胎',
                '丑' => '养',
                '子' => '长生',
            ],
            '壬' => [
                '酉' => '沐浴',
                '戌' => '冠带',
                '亥' => '临官',
                '子' => '帝旺',
                '丑' => '衰',
                '寅' => '病',
                '卯' => '死',
                '辰' => '墓',
                '巳' => '绝',
                '午' => '胎',
                '未' => '养',
                '申' => '长生',
            ],
            '癸' => [
                '寅' => '沐浴',
                '丑' => '冠带',
                '子' => '临官',
                '亥' => '帝旺',
                '戌' => '衰',
                '酉' => '病',
                '申' => '死',
                '未' => '墓',
                '午' => '绝',
                '巳' => '胎',
                '辰' => '养',
                '卯' => '长生',
            ],
        ],
    ];
    /**
     * 八字相关数据
     * @var array
     * bazi 当前生辰的八字
     * birth_time 出生时间戳
     * st_time 大运起运时间
     * dayun 大运信息
     */
    public $data = [
        'bazi' => null,
        'score' => ['金' => 0, '木' => 0, '水' => 0, '火' => 0, '土' => 0,],
        'wuxing_perc' => ['金' => 0, '木' => 0, '水' => 0, '火' => 0, '土' => 0,],
        'shishen_wuxing' => null,
        'lushen' => null,
        'birth_time' => null,
        'st_time' => null,
        'dayun' => null,
        'dayun_now' => null,
        'liunian_now' => null,
        'shenwang' => null,
        'liunianzhushen' => null,
        'ganzhibuxie' => null,
        'anjing' => null,
        'shuangchong' => null,
        'donggong' => null,
        'or_shanggong' => null,
        'or_shangshen' => null,
        'shanggong' => null,
        'shangshen' => null,
        'liunian_lichun' => true,
        'siling' => null,
        'is_need_show_tip' => 0,
    ];

    private function __construct()
    {
    }

    /**
     * 获取静态实例对象
     * @param array $option
     * @return Horoscope
     */
    public static function getInstance($option = [])
    {
        if (!(self::$_instance instanceof self))
        {
            self::$_instance = new self();
        }
        if (!empty($option))
        {
            if (!empty($option['recode']))
            {
                self::$_instance->option['recode'] = $option['recode'];
                // 出生时间时间戳 存入 data
                self::$_instance->data['birth_time'] = strtotime($option['recode']['year'] . '-' . $option['recode']['month'] . '-' . $option['recode']['day'] . ' ' . $option['recode']['hour'] . ':' . $option['recode']['minute']);
            }
            if (!empty($option['advance']))
            {
                self::$_instance->option['advance'] = $option['advance'];
            }
            if (isset($option['time_type']) && in_array($option['time_type'], [0 , 1], false))
            {
                self::$_instance->option['time_type'] = (int)$option['time_type'];
            }
            if (isset($option['time_start']) && in_array($option['time_start'], [0 , 23], false))
            {
                self::$_instance->option['time_start'] = (int)$option['time_start'];
            }
            if (isset($option['shensha']) && in_array($option['shensha'], [0 , 1, 2], false))
            {
                self::$_instance->option['shensha'] = (int)$option['shensha'];
            }
        }
        if (!empty(self::$_instance->option['recode']))
        {
            // 获取命主太阳度数
            $sunDeg = Astrolog::getInstance()->setExecPrefix(config('astrolog.prefix'))->getPlanetOriginData('0', self::$_instance->option['recode'])[0] * 1;
            //获取八字
            self::$_instance->getBazi(self::$_instance->data['birth_time'], $sunDeg, true);
            self::$_instance->data['siling'] = self::$_instance->baziSiling($sunDeg);
        }
        return self::$_instance;
    }

    /**
     * @return array
     */
    public function yearConclusion()
    {
        $result = [];

        $this->getAllData();
        $this->getyearConclusionData();

        $topic = $this->getTopic();
        $point = $this->getPoint();

        $result['topic'] = $topic;
        $result['point'] = $point;

        return $result;
    }

    /**
     * 获取年运主题
     * @param array $dongshenSort
     * @param null $max_dongshen
     * @return integer
     */
    public function getTopic($dongshenSort = [], $max_dongshen = null)
    {
        $liu = $this->data['liunian_now'];
        $liu_benqi = $this->param['canggan'][$liu[1]][0];

        $bazi = $this->data['bazi'];

        $rigan = $bazi[5];

        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];
        $liuzhi_shishen = $this->param['shishen'][$liu_benqi][$rigan];

        $yearsOld = $this->option['advance']['year'] - $this->option['recode']['year'];

        /**
         * 折冲之年
         * 与大运或日柱双冲
         */
        $zhu_temp = [
            [$rigan, $bazi[6]],
        ];

        if ($this->data['dayun_now'] != null)
        {
            $zhu_temp[] = $this->data['dayun_now'];
        }
        if ($this->is_shuangchong($liu, $zhu_temp))
        {
            return 0;
        }

        /**
         * 缭乱之年
         * 与命运形成多组刑冲穿（三组以上）
         */
        $zhis = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];

        if ($this->data['dayun_now'] != null) $zhis[] = $this->data['dayun_now'][1];

        $xcc_num = 0;

        foreach ($zhis as $zhi)
        {
            if ($this->is_xing($zhi, $liu[1]) || $this->is_liuchong($zhi, $liu[1]) || $this->is_liuhai($zhi, $liu[1]))
            {
                $xcc_num++;
            }
        }
        if ($xcc_num >= 3)
        {
            return 1;
        }

        /**
         * 逆流之年
         * 与日柱干合支刑或干合支穿
         * 女，主神正官
         * 男，主神正官
         * 男，主神正财
         * 女，主神正财
         */
        if ($this->is_wuhe($rigan, $liu[0])
            && ($this->is_xing($bazi[6], $liu[1]) || $this->is_liuhai($bazi[6], $liu[1])))
        {
            // 男
            if ($this->option['recode']['type'] == 1)
            {
                if (in_array('正官', $this->data['liunianzhushen']))
                {
                    return 3;
                } elseif (in_array('正财', $this->data['liunianzhushen']))
                {
                    return 4;
                }
            } // 女
            else
            {
                if (in_array('正官', $this->data['liunianzhushen']))
                {
                    return 2;
                } elseif (in_array('正财', $this->data['liunianzhushen']))
                {
                    return 5;
                }
            }
        }
        $donggong = $this->data['donggong'];
        $dongshen = $this->data['dongshen'];

        $shanggong = $this->data['shanggong'];
        $shangshen = $this->data['shangshen'];

        $max_donggong = max($donggong);
        if (empty($dongshenSort))
        {
            $dongshenSort = $this->data['dongshen'];
            arsort($dongshenSort);
        }
        if ($max_dongshen === null)
        {
            $max_dongshen = array_shift($dongshenSort);
        }
        $is_yin_dongshen = $dongshen['正印'] > 0.5 || $dongshen['偏印'] > 0.5;
        $is_cai_dongshen = $dongshen['正财'] > 0.5 || $dongshen['偏财'] > 0.5;
        $is_sha_dongshen = $dongshen['正官'] > 0.5 || $dongshen['七杀'] > 0.5;
        $is_shi_dongshen = $dongshen['食神'] > 0.5 || $dongshen['伤官'] > 0.5;
        $y_zhi_benqi = $this->param['canggan'][$bazi[2]][0];

        $gan_bijie_num = 0;
        if (in_array($this->param['shishen'][$bazi[1]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;
        if (in_array($this->param['shishen'][$bazi[3]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;
        if (in_array($this->param['shishen'][$bazi[7]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;
        if ($this->data['dayun_now'] != null
            && in_array($this->param['shishen'][$this->data['dayun_now'][0]][$rigan], ['比肩', '劫财'])) $gan_bijie_num++;

        /**
         * 年宫最高且受伤
         * 母忧之年 此时印星也是动神（指数高于0.5）
         * 父忧之年 此时财星也是动神
         * 注：财印都动则优先受伤度高者
         */
        if ($this->data['donggong'][0] == $max_donggong && $shanggong[0] > 1)
        {
            // 母忧之年
            if ($is_yin_dongshen && !$is_cai_dongshen)
            {
                return 6;
            } // 父忧之年
            elseif (!$is_yin_dongshen && $is_cai_dongshen)
            {
                return 7;
            } // 财印都动
            elseif ($is_yin_dongshen && $is_cai_dongshen)
            {
                // 优先受伤度高者
                $shangs = [
                    $shangshen['正印'],
                    $shangshen['偏印'],
                    $shangshen['正财'],
                    $shangshen['偏财'],
                ];

                $max_shang = max($shangs);
                // 母忧之年
                if ($shangshen['正印'] == $max_shang || $shangshen['偏印'] == $max_shang)
                {
                    return 6;
                } // 父忧之年
                else
                {
                    return 7;
                }
            }
        }

        /**
         * 日宫最高且受伤
         * 情伤之年  女命，官杀也是动神；男命，财星也是动神
         * 思虑之年  正印或食神受伤
         * 磨炼之年  七杀为最高动神，且，如七杀透出天干未被合
         * 晦名之年  男命，正官受伤
         * 劳身之年  禄受伤
         */
        if ($this->data['donggong'][2] == $max_donggong && $shanggong[2] >= 1)
        {
            // 情伤之年
            if (($this->option['recode']['type'] == 1 && $is_cai_dongshen)
                || ($this->option['recode']['type'] != 1 && $is_sha_dongshen))
            {
                return 8;
            }
            // 思虑之年
            if ($shangshen['正印'] > 1 || $shangshen['食神'] >= 1)
            {
                return 9;
            }
            // 磨炼之年10 七杀为最高动神，且，如七杀透出天干未被合  透表示任意天干有七杀
            if ($dongshen['七杀'] == $max_dongshen
                &&
                (
                    ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $bazi[3])
                        && !$this->is_wuhe($bazi[1], $bazi[5])
                        && !$this->is_wuhe($bazi[1], $bazi[7])
                    )
                    &&
                    ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[3], $bazi[1])
                        && !$this->is_wuhe($bazi[3], $bazi[5])
                        && !$this->is_wuhe($bazi[3], $bazi[7])
                    )
                    &&
                    ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[7], $bazi[1])
                        && !$this->is_wuhe($bazi[7], $bazi[3])
                        && !$this->is_wuhe($bazi[7], $bazi[5])
                    )
                    &&
                    ($liugan_shishen == '七杀'
                        && !$this->is_wuhe($liu[0], $bazi[1])
                        && !$this->is_wuhe($liu[0], $bazi[3])
                        && !$this->is_wuhe($liu[0], $bazi[5])
                    )
                    &&
                    ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                        && !$this->is_wuhe($this->data['dayun_now'][0], $bazi[1])
                        && !$this->is_wuhe($this->data['dayun_now'][0], $bazi[3])
                        && !$this->is_wuhe($this->data['dayun_now'][0], $bazi[5])
                    )
                )
            )
            {
                return 10;
            }
            // 晦名之年11
            if ($this->option['recode']['type'] == 1 && $shangshen['正官'] >= 1)
            {
                return 11;
            }
            // 劳身之年12 禄受伤  检测年月日时运流年是否有日干的禄
            if (($this->is_lushen($rigan, $bazi[2])
                    && $shangshen[$this->param['shishen'][$y_zhi_benqi][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $bazi[4])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $bazi[6])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $bazi[8])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan]] >= 1)
                ||
                ($this->data['dayun_now'] != null && $this->is_lushen($rigan, $this->data['dayun_now'][1])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan]] >= 1)
                ||
                ($this->is_lushen($rigan, $liu[1])
                    && $shangshen[$this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan]] >= 1)
            )
            {
                return 12;
            }
        }
        /**
         * 日宫最高但未受伤
         * 桃花之年  女命，官杀动神；男命，财星动神
         * 名位之年  男命，官星动神且未受伤   官星 为正官
         * 创业之年  男命，七杀动神
         * 文书之年  印星动神且未受伤
         * 华秀之年  食神动神且未受伤，本命身旺
         * 权名之年  食神动神且未受伤，命运天干有七杀
         */
        if ($this->data['donggong'][2] == $max_donggong && $shanggong[2] < 1)
        {
            // 桃花之年 男
            if ($this->option['recode']['type'] == 1 && $is_cai_dongshen)
            {
                return 13;
            } // 桃花之年 女
            elseif ($this->option['recode']['type'] != 1 && $is_sha_dongshen)
            {
                return 14;
            }
            if ($this->option['recode']['type'] == 1)
            {
                // 名位之年
                if ($dongshen['正官'] > 0.5 && $shangshen['正官'] < 1)
                {
                    return 15;
                }
                // 创业之年
                if ($dongshen['七杀'] > 0.5)
                {
                    return 16;
                }
                // 文书之年
                if ($is_yin_dongshen && $shangshen['正印'] < 0.5 && $shangshen['偏印'] < 0.5)
                {
                    return 17;
                }
                if ($dongshen['食神'] > 0.5 && $shangshen['食神'] < 1)
                {
                    // 华秀之年
                    if ($this->data['shenwang'])
                    {
                        return 18;
                    } // 权名之年 命运天干有七杀
                    elseif ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        || $this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        || $this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        || ($this->data['dayun_now'] != null && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'))
                    {
                        return 19;
                    }
                }
            }
        }

        /**
         * 时宫最高且受伤
         * 子殇之年
         * 女命，食伤动神；男命，官杀动神
         */
        if ($this->data['donggong'][3] == $max_donggong && $shanggong[3] >= 1
            && $yearsOld > 18 && $yearsOld <= 45)
        {
            if ($this->option['recode']['type'] == 1 && $is_sha_dongshen)
            {
                return 20;
            } elseif ($this->option['recode']['type'] != 1 && $is_shi_dongshen)
            {
                return 21;
            }
        }

        /**
         * 时宫最高但未受伤（大于18岁）
         *  2024-09-23 修改为  大于18岁 小于45岁
         * 子女之年
         * 女命，食伤动神且未伤；男命，官杀动神且未伤
         */
        if ($this->data['donggong'][3] == $max_donggong && $shanggong[3] < 1
            && $yearsOld > 18 && $yearsOld <= 45)
        {
            if (($this->option['recode']['type'] == 1 && $is_sha_dongshen && $shangshen['正官'] < 1 && $shangshen['七杀'] < 1)
                || ($this->option['recode']['type'] != 1 && $is_shi_dongshen && $shangshen['食神'] < 1 && $shangshen['伤官'] < 1))
            {
                return 22;
            }
        }

        /**
         * 比肩最高
         * 劳身之年  受伤
         * 不受伤  取次高的十神，转入后续判定
         */
        if ($dongshen['比肩'] == $max_dongshen)
        {
            if ($shangshen['比肩'] >= 1)
            {
                return 12;
            } else
            {
                // 次高的十神 赋值为最大
                $max_dongshen = array_shift($dongshenSort);
            }
        }

        /**
         * 劫财最高
         * 争财之年  年干或支本气为劫财，且劫财不与杀合
         * 命运劫财被流干合或克；流干劫财被命运七杀合
         *      男，权位之年
         *      女，夺情之年
         * 其它 取次高的十神，转入后续判定
         */
        if ($dongshen['劫财'] == $max_dongshen)
        {
            // 年干或支本气为劫财，且劫财不与杀合
            // 争财之年
            if (($this->param['shishen'][$bazi[1]][$rigan] == '劫财'
                    && ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $bazi[3]))
                    && ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $bazi[7]))
                    && ($liugan_shishen == '七杀'
                        && !$this->is_wuhe($bazi[1], $liu[0]))
                    && ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                        && !$this->is_wuhe($bazi[1], $this->data['dayun_now'][0]))
                )
                || (
                    $this->param['shishen'][$y_zhi_benqi][$rigan] == '劫财'
                    && ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $bazi[1]))
                    && ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $bazi[3]))
                    && ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $bazi[7]))
                    && ($liugan_shishen == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $liu[0]))
                    && ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                        && !$this->is_wuhe($y_zhi_benqi, $this->data['dayun_now'][0]))
                )
            )
            {
                return 23;
            }// 命运劫财被流干合或克；流干劫财被命运七杀合
            // 命运干有劫财，流干有七杀  且 七杀与劫财五合；或命运干有劫财，流干有正官
            elseif (
                ($this->param['shishen'][$bazi[1]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $bazi[1])))
                ||
                ($this->param['shishen'][$bazi[3]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $bazi[3])))
                ||
                ($this->param['shishen'][$bazi[7]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $bazi[7])))
                ||
                ($this->data['dayun_now'] != null
                    && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '劫财'
                    && ($liugan_shishen == '七杀'
                        && $this->is_wuhe($liu[0], $this->data['dayun_now'][0])))
                ||
                (
                    ($this->param['shishen'][$bazi[1]][$rigan] == '劫财'
                        || $this->param['shishen'][$bazi[3]][$rigan] == '劫财'
                        || $this->param['shishen'][$bazi[7]][$rigan] == '劫财'
                        || ($this->data['dayun_now'] != null
                            && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '劫财')
                    )
                    && $liugan_shishen == '正官'
                )
                ||
                ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $bazi[1]))
                ||
                ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $bazi[3]))
                ||
                ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $bazi[7]))
                ||
                ($this->data['dayun_now'] != null
                    && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                    && $liugan_shishen == '劫财'
                    && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
            )
            {
                if ($this->option['recode']['type'] == 1)
                {
                    return 24;
                } else
                {
                    return 25;
                }
            } // 其它 取次高的十神，转入后续判定
            else
            {
                $max_dongshen = array_shift($dongshenSort);
            }
        }

        /**
         * 食神最高
         * 思虑之年  受伤
         * 华秀之年  不受伤
         */
        if ($dongshen['食神'] == $max_dongshen)
        {
            if ($shangshen['食神'] >= 1)
            {
                return 9;
            } else
            {
                return 18;
            }
        }

        /**
         * 伤官最高
         * 流干伤官被合，且无地支伤官冲穿官星
         *  名位之年    若流支为官或命运天干有官
         *  华秀之年    其它
         * 晦名之年  伤官与官所在柱冲穿；或官星受伤
         * 才艺之年 官星不受伤
         */
        if ($dongshen['伤官'] == $max_dongshen)
        {
            // 流干伤官 被合，且无地支伤官冲穿官星
            // 即：流年天干是伤官，被其它干五合，同时，流支不与命运地支中的官星冲穿
            if ($liugan_shishen == '伤官'
                &&
                (
                    $this->is_wuhe($liu[0], $bazi[1])
                    || $this->is_wuhe($liu[0], $bazi[3])
                    || $this->is_wuhe($liu[0], $bazi[7])
                    || ($this->data['dayun_now'] != null && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
                )
                &&
                (
                    ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[2])
                        && !$this->is_liuhai($liu[1], $bazi[2]))
                    ||
                    ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[4])
                        && !$this->is_liuhai($liu[1], $bazi[4]))
                    ||
                    ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[6])
                        && !$this->is_liuhai($liu[1], $bazi[6]))
                    ||
                    ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $bazi[8])
                        && !$this->is_liuhai($liu[1], $bazi[8]))
                    ||
                    ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '正官'
                        && !$this->is_liuchong($liu[1], $this->data['dayun_now'][1])
                        && !$this->is_liuhai($liu[1], $this->data['dayun_now'][1]))
                )
            )
            {
                // 名位之年
                if ($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] == '正官'
                    || $this->param['shishen'][$bazi[1]][$rigan] == '正官'
                    || $this->param['shishen'][$bazi[3]][$rigan] == '正官'
                    || $this->param['shishen'][$bazi[7]][$rigan] == '正官'
                    || ($this->data['dayun_now'] != null
                        && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '正官')
                )
                {
                    return 15;
                } // 华秀之年
                else
                {
                    return 18;
                }
            } // 晦名之年 伤官与官所在柱冲穿；或官星受伤
            // 即：伤官与官所在柱冲穿，是指，若某柱有正官存在，无论在干还是支，伤官与该柱地支冲穿
            elseif ($shangshen['正官'] >= 1
                ||
                (
                    (
                        ($liugan_shishen == '正官'
                            || $liuzhi_shishen == '正官')
                        &&
                        (
                            ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[2], $liu[1])
                                    || $this->is_liuhai($bazi[2], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $liu[1])
                                    || $this->is_liuhai($bazi[4], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $liu[1])
                                    || $this->is_liuhai($bazi[6], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $liu[1])
                                    || $this->is_liuhai($bazi[8], $liu[1])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $liu[1])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $liu[1])))
                        )
                    )
                    ||
                    (
                        $this->data['dayun_now'] != null
                        && ($this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '正官')
                        &&
                        (
                            ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[2], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[2], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[4], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[6], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $this->data['dayun_now'][1])
                                    || $this->is_liuhai($bazi[8], $this->data['dayun_now'][1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($liu[1], $liu[1])
                                    || $this->is_liuhai($liu[1], $liu[1])))
                        )
                    )
                    ||
                    (
                        ($this->param['shishen'][$bazi[1]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '正官')
                        &&
                        (
                            ($liugan_shishen == '伤官'
                                && ($this->is_liuchong($bazi[2], $liu[1])
                                    || $this->is_liuhai($bazi[2], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $bazi[2])
                                    || $this->is_liuhai($bazi[4], $bazi[2])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $bazi[2])
                                    || $this->is_liuhai($bazi[6], $bazi[2])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $bazi[2])
                                    || $this->is_liuhai($bazi[8], $bazi[2])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $bazi[2])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $bazi[2])))
                        )
                    )
                    ||
                    (
                        ($this->param['shishen'][$bazi[3]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '正官')
                        &&
                        (
                            ($liugan_shishen == '伤官'
                                && ($this->is_liuchong($bazi[4], $liu[1])
                                    || $this->is_liuhai($bazi[4], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $bazi[2])
                                    || $this->is_liuhai($bazi[4], $bazi[2])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $bazi[4])
                                    || $this->is_liuhai($bazi[6], $bazi[4])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $bazi[4])
                                    || $this->is_liuhai($bazi[8], $bazi[4])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $bazi[4])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $bazi[4])))
                        )
                    )
                    ||
                    (
                        ($this->param['shishen'][$bazi[7]][$rigan] == '正官'
                            || $this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan] == '正官')
                        &&
                        (
                            ($liugan_shishen == '伤官'
                                && ($this->is_liuchong($bazi[8], $liu[1])
                                    || $this->is_liuhai($bazi[8], $liu[1])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[4], $bazi[8])
                                    || $this->is_liuhai($bazi[4], $bazi[8])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[6], $bazi[8])
                                    || $this->is_liuhai($bazi[6], $bazi[8])))
                            ||
                            ($this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($bazi[8], $bazi[2])
                                    || $this->is_liuhai($bazi[8], $bazi[2])))
                            ||
                            ($this->data['dayun_now'] != null
                                && $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan] == '伤官'
                                && ($this->is_liuchong($this->data['dayun_now'][1], $bazi[8])
                                    || $this->is_liuhai($this->data['dayun_now'][1], $bazi[8])))
                        )
                    )
                )
            )
            {
                return 11;
            } // 才艺之年 官星不受伤
            elseif ($shangshen['正官'] < 1)
            {
                return 26;
            }
        }


        /**
         * 正财最高
         * 散财之年 27 受伤，或出现两个以上天干合正财 或流干流支一个是劫财一个是财星 20190117
         * 进财之年  不受伤，无分夺，印不受伤  (分夺是天干有多个比劫);或 印有受伤，但流支为正偏财、正官、食神且不与命运刑穿
         *  命运年天干及年支本气都没有偏财 28
         *  有偏财 29
         * 破印之年  印受伤
         */
        if ($dongshen['正财'] == $max_dongshen)
        {
            $gan_he_zhengcai_num = 0;
            if ($this->param['shishen'][$bazi[1]][$rigan] == '正财')
            {
                if ($this->is_wuhe($bazi[1], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[1], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[1], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[1], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($bazi[1], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($this->param['shishen'][$bazi[3]][$rigan] == '正财')
            {
                if ($this->is_wuhe($bazi[3], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[3], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[3], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[3], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($bazi[3], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($this->param['shishen'][$bazi[7]][$rigan] == '正财')
            {
                if ($this->is_wuhe($bazi[7], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[7], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[7], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($bazi[7], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($bazi[7], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($liugan_shishen == '正财')
            {
                if ($this->is_wuhe($liu[0], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($liu[0], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($liu[0], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($liu[0], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->data['dayun_now'] != null && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }
            if ($this->data['dayun_now'] != null
                && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '正财')
            {
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[1]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[3]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[5]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $bazi[7]))
                {
                    $gan_he_zhengcai_num++;
                }
                if ($this->is_wuhe($this->data['dayun_now'][0], $liu[0]))
                {
                    $gan_he_zhengcai_num++;
                }
            }


            // 散财之年  受伤，或出现两个以上天干合正财
            //  或流干流支一个是劫财一个是财星 20190117
            if ($shangshen['正财'] >= 1 || $gan_he_zhengcai_num >= 2
                || ($liugan_shishen == '劫财' && in_array($liuzhi_shishen, ['正财', '偏财']))
                || ($liuzhi_shishen == '劫财' && in_array($liugan_shishen, ['正财', '偏财']))
            )
            {
                return 27;
            } // 进财之年
            elseif (
                ($shangshen['正财'] < 1 && $shangshen['正印'] < 1 && $shangshen['偏印'] < 1 && $gan_bijie_num == 0)
                ||
                (
                    ($shangshen['正印'] >= 1 || $shangshen['偏印'] >= 1)
                    && in_array($liuzhi_shishen, ['正财', '偏财', '正官', '食神'])
                    && !$this->is_xing($liu[1], $bazi[2]) && !$this->is_liuhai($liu[1], $bazi[2])
                    && !$this->is_xing($liu[1], $bazi[4]) && !$this->is_liuhai($liu[1], $bazi[4])
                    && !$this->is_xing($liu[1], $bazi[6]) && !$this->is_liuhai($liu[1], $bazi[6])
                    && !$this->is_xing($liu[1], $bazi[8]) && !$this->is_liuhai($liu[1], $bazi[8])
                    && ($this->data['dayun_now'] != null && !$this->is_xing($liu[1], $this->data['dayun_now'][1]) && !$this->is_liuhai($liu[1], $this->data['dayun_now'][1]))
                )
            )
            {
                // 命运年天干及年支本气都没有偏财
                if ($this->param['shishen'][$y_zhi_benqi][$rigan] != '偏财'
                    && $this->param['shishen'][$bazi[1]][$rigan] != '偏财')
                {
                    return 28;
                } // 有偏财
                else
                {
                    return 29;
                }
            } // 破印之年
            elseif ($shangshen['正印'] >= 1 && $shangshen['偏印'] >= 1)
            {
                return 30;
            }
        }

        /**
         * 偏财最高
         * 散财之年 27 受伤，年支比劫或命运天干比劫两座以上； 或流干流支一个是劫财一个是财星 20190117
         * 进财之年 不受伤，且印不受伤
         * 破印之年 30 印受伤
         */
        if ($dongshen['偏财'] == $max_dongshen)
        {
            // 散财之年
            //  或流干流支一个是劫财一个是财星 20190117
            if (
                (
                    $shangshen['偏财'] >= 1
                    && (in_array($this->param['shishen'][$y_zhi_benqi][$rigan], ['比肩', '劫财'])
                        || $gan_bijie_num >= 2)
                )
                ||
                (
                    ($liugan_shishen == '劫财' && in_array($liuzhi_shishen, ['正财', '偏财']))
                    || ($liuzhi_shishen == '劫财' && in_array($liugan_shishen, ['正财', '偏财']))
                )
            )
            {
                return 27;
            } // 进财之年
            elseif ($shangshen['偏财'] < 1 && $shangshen['正印'] < 1 && $shangshen['偏印'] < 1)
            {
                return 29;
            } // 破印之年
            elseif ($shangshen['正印'] >= 1 && $shangshen['偏印'] >= 1)
            {
                return 30;
            }
        }

        /**
         * 正官最高
         * 晦名之年  受伤
         * 名位之年 不受伤
         */
        if ($dongshen['正官'] == $max_dongshen)
        {
            if ($shangshen['正官'] >= 1)
            {
                return 11;
            } else
            {
                return 15;
            }
        }

        /**
         * 七杀最高
         * 权名之年  命运七杀被流干合，或流干七杀被岁运合
         * 磨砺之年  本命官杀五行比重高于比劫+印星，或流支与本命日支冲穿刑，或流支与日干禄冲穿刑
         * 创业之年  其它
         */
        if ($dongshen['七杀'] == $max_dongshen)
        {
            // 权名之年  命运七杀被流干合，或流干七杀被岁运合
            if (
                ($this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $bazi[1]))
                ||
                ($this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $bazi[3]))
                ||
                ($this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $bazi[7]))
                ||
                ($this->data['dayun_now'] != null
                    && $this->param['shishen'][$this->data['dayun_now'][0]][$rigan] == '七杀'
                    && $this->is_wuhe($liu[0], $this->data['dayun_now'][0]))
                ||
                (
                    $liugan_shishen == '七杀'
                    &&
                    (
                        $this->is_wuhe($bazi[1], $liu[0])
                        || ($this->data['dayun_now'] != null
                            && $this->is_wuhe($bazi[1], $this->data['dayun_now'][0]))
                    )
                )
            )
            {
                return 19;
            } // 磨砺之年  本命官杀五行比重高于比劫+印星，或流支与本命日支冲穿刑，或流支与日干禄冲穿刑
            elseif (
                (
                    $this->data['shishen_wuxing']['官杀'] > $this->data['shishen_wuxing']['比劫']
                    + $this->data['shishen_wuxing']['印']
                )
                || $this->is_liuchong($liu[1], $bazi[6])
                || $this->is_xing($liu[1], $bazi[6])
                || $this->is_liuhai($liu[1], $bazi[6])
                || ($this->is_lushen($rigan, $bazi[2])
                    && ($this->is_xing($liu[1], $bazi[2])
                        || $this->is_liuchong($liu[1], $bazi[2])
                        || $this->is_liuhai($liu[1], $bazi[2])))
                || ($this->is_lushen($rigan, $bazi[2])
                    && ($this->is_xing($liu[1], $bazi[2])
                        || $this->is_liuchong($liu[1], $bazi[2])
                        || $this->is_liuhai($liu[1], $bazi[2])))
                || ($this->is_lushen($rigan, $bazi[4])
                    && ($this->is_xing($liu[1], $bazi[4])
                        || $this->is_liuchong($liu[1], $bazi[4])
                        || $this->is_liuhai($liu[1], $bazi[4])))
                || ($this->is_lushen($rigan, $bazi[6])
                    && ($this->is_xing($liu[1], $bazi[6])
                        || $this->is_liuchong($liu[1], $bazi[6])
                        || $this->is_liuhai($liu[1], $bazi[6])))
                || ($this->is_lushen($rigan, $bazi[8])
                    && ($this->is_xing($liu[1], $bazi[8])
                        || $this->is_liuchong($liu[1], $bazi[8])
                        || $this->is_liuhai($liu[1], $bazi[8])))
                || ($this->data['dayun_now'] != null
                    && $this->is_lushen($rigan, $this->data['dayun_now'][1])
                    && ($this->is_xing($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuchong($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuhai($liu[1], $this->data['dayun_now'][1])))
            )
            {
                // 磨砺之年词条 为 磨炼之年
                return 10;
            } // 创业之年
            else
            {
                return 16;
            }
        }

        /**
         * 正印最高
         * 破印之年 受伤
         * 不受伤
         *  迁动之年  流年冲命运
         *  安乐之年  不冲
         */
        if ($dongshen['正印'] == $max_dongshen)
        {
            // 破印之年
            if ($shangshen['正印'] >= 1)
            {
                return 30;
            } else
            {
                // 迁动之年  流年冲命运
                if ($this->is_liuchong($liu[1], $bazi[2])
                    || $this->is_liuchong($liu[1], $bazi[4])
                    || $this->is_liuchong($liu[1], $bazi[6])
                    || $this->is_liuchong($liu[1], $bazi[7])
                    || ($this->data['dayun_now'] != null && $this->is_liuchong($liu[1], $this->data['dayun_now'][1]))
                )
                {
                    return 31;
                } // 安乐之年
                else
                {
                    return 32;
                }
            }
        }

        /**
         * 偏印最高
         * 夺食之年  食神受伤
         * 食神不受伤
         *  迁动之年  流年冲命运
         *  不冲  取次高的十神，重新判定
         */
        if ($dongshen['偏印'] == $max_dongshen)
        {
            // 夺食之年
            if ($shangshen['食神'] >= 1)
            {
                return 33;
            } else
            {
                // 迁动之年  流年冲命运
                if ($this->is_liuchong($liu[1], $bazi[2])
                    || $this->is_liuchong($liu[1], $bazi[4])
                    || $this->is_liuchong($liu[1], $bazi[6])
                    || $this->is_liuchong($liu[1], $bazi[7])
                    || ($this->data['dayun_now'] != null && $this->is_liuchong($liu[1], $this->data['dayun_now'][1]))
                )
                {
                    return 31;
                } // 不冲  取次高的十神，重新判定
                else
                {
                    $max_dongshen = array_shift($dongshenSort);
                    return self::getTopic($dongshenSort, $max_dongshen);
                }
            }
        }
        return -1;
    }

    /**
     * 年运概括添加
     * 变量
     * 20XX年，调取年份
     * Y 调取木星所在宫位，每月取一次数据，取所在宫位次数多的
     *      1命宫、2财务宫、3外出宫、4父母宫、5恋爱宫、6劳务宫、7婚姻宫、8偏财宫、9旅行宫、10事业宫、11福德宫、12灵性宫
     * Z 调取土星所在宫位，每月取一次数据，取所在宫位次数多的
     * W 木星所在宫位Y
     *  1宫 身体健康、个人成长
     *  2 财富、物质享受
     *  3 学习、出行
     *  4 家庭、房产
     *  5 情感、娱乐、创作
     *  6 工作
     *  7 婚恋、合作、交际
     *  8 理财、商业
     *  9 旅游、教育
     *  10 事业
     *  11 交际、事业
     *  12 精神成长
     * T
     *  T=1宫
     *  2
     *  3
     *  4
     * S 当年的属相
     * R
     *  当流支=本命年支           是你的本命年，但本命年也有好有坏，不必过于担心。
     *  当流支与本命年支相冲       你今年有一点犯太岁，但一般来说并无大碍。
     *  当流支与本命年支相穿       你今年有轻微的犯太岁，但一般没什么大问题。
     *  当流支与本命年支相刑       你今年有轻微的犯太岁，但一般没什么大问题。
     *  其它                    你与太岁并不冲犯，民俗认为是平安喜乐的好年份。
     * Y不等于Z时输出词条
     *      20XX年，木星会在你的Y宫、土星会在你的Z宫停留较长时间，你会在W方面得到更多的机会或好运气，并在T方面落实一些事情，学会去面对和承担，认真对待，你就能借此解决一些存留已久的问题。传统上，这一年是S年，R
     * Y等于Z时输出词条
     *      20XX年，木星和土星都会在你的Y宫停留很久，你会在W方面得到更多的机会或好运气，并能落实一些事情，学会去面对和承担，认真对待，你就能借此解决一些存留已久的问题。传统上，这一年是S年，R
     */
    public function getTopicExtend()
    {
//        $liu = $this->data['liunian_now'];
//        $bazi = $this->data['bazi'];
//        $rigan = $bazi[5];

    }

    /**
     * 获取年运重点
     * @return array
     */
    public function getPoint()
    {
        $result = [];

        $advanceInfo = [
            'year' => $this->option['advance']['year'],
            'month' => 3,
            'day' => 1,
            'hour' => 12,
            'minute' => 0,
            'timezone' => 8,
            'is_summer' => 0,
            'longitude' => $this->option['recode']['longitude'],// 使用本命经纬度
            'latitude' => $this->option['recode']['latitude'],// 使用本命经纬度
        ];

        $Astrolog = Astrolog::getInstance();

        $Astrolog->setRecode1($this->option['recode'])
            ->setAdvance($advanceInfo)
            ->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(false)
            ->setUserSetting(config('astroset.setting1'))
            ->setGetDatas(['thirdprogressed']);

        $Astrolog->getAstroDatas();
        // 3月1号三限
        $source1 = $Astrolog->getAstroDatas()->getDatas('thirdprogressed');

        // 10月1号三限
        $advanceInfo['month'] = 10;
        $source2 = $Astrolog->setAdvance($advanceInfo)->getAstroDatas()->getDatas('thirdprogressed');
        // 7月1号三限
        $advanceInfo['month'] = 7;
        $source3 = $Astrolog->setAdvance($advanceInfo)->getAstroDatas()->getDatas('thirdprogressed');

        $liu = $this->data['liunian_now'];
        $bazi = $this->data['bazi'];
        $rigan = $bazi[5];
        $donggong = $this->data['donggong'];
        $dongshen = $dongshenSort = $this->data['dongshen'];
        $shanggong = $this->data['shanggong'];
        $shangshen = $this->data['shangshen'];
        $shishen_wuxing = $this->data['shishen_wuxing'];
        $liu_benqi = $this->param['canggan'][$liu[1]][0];
        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];
        $liuzhi_shishen = $this->param['shishen'][$liu_benqi][$rigan];
        $dayun = $this->data['dayun_now'] != null ? $this->data['dayun_now'] : null;
        $dayun_benqi = $dayun != null ? $this->param['canggan'][$dayun[1]][0] : null;
        /**
         * 情感纠葛
         * 三限是否有金冥刑冲相位（分别检测3月1号和10月1号，其一满足，下同）
         */
        if ((isset($source1['planets'][3]['phase']['3-9']) && in_array($source1['planets'][3]['phase']['3-9']['phase_e'], [90, 180]))
            || (isset($source2['planets'][3]['phase']['3-9']) && in_array($source2['planets'][3]['phase']['3-9']['phase_e'], [90, 180])))
        {
            $result[] = 0;
        }

        /**
         * 桃花
         * 三限是否有金木/金火/日金相位，且其一星在5/7宫，金星不与土星海王刑冲
         */
        $is_1p5_inhouse_57 = in_array($source1['planets'][3]['in_house_id'], [5, 7]);
        $is_2p5_inhouse_57 = in_array($source2['planets'][3]['in_house_id'], [5, 7]);
        if (
            (
                (!isset($source1['planets'][3]['phase']['3-6']) || !in_array($source1['planets'][3]['phase']['3-6']['phase_e'], [90, 180]))
                && (!isset($source1['planets'][3]['phase']['3-8']) || !in_array($source1['planets'][3]['phase']['3-8']['phase_e'], [90, 180]))
                &&
                (
                    (isset($source1['planets'][3]['phase']['3-0'])
                        && ($is_1p5_inhouse_57 || in_array($source1['planets'][0]['in_house_id'], [5, 7])))
                    || (isset($source1['planets'][3]['phase']['3-4'])
                        && ($is_1p5_inhouse_57 || in_array($source1['planets'][4]['in_house_id'], [5, 7])))
                    || (isset($source1['planets'][3]['phase']['3-5'])
                        && ($is_1p5_inhouse_57 || in_array($source1['planets'][5]['in_house_id'], [5, 7])))
                )
            )
            ||
            (
                (!isset($source2['planets'][3]['phase']['3-6']) || !in_array($source2['planets'][3]['phase']['3-6']['phase_e'], [90, 180]))
                && (!isset($source2['planets'][3]['phase']['3-8']) || !in_array($source2['planets'][3]['phase']['3-8']['phase_e'], [90, 180]))
                &&
                (
                    (isset($source2['planets'][3]['phase']['3-0'])
                        && ($is_2p5_inhouse_57 || in_array($source2['planets'][0]['in_house_id'], [5, 7])))
                    || (isset($source2['planets'][3]['phase']['3-4'])
                        && ($is_2p5_inhouse_57 || in_array($source2['planets'][4]['in_house_id'], [5, 7])))
                    || (isset($source2['planets'][3]['phase']['3-5'])
                        && ($is_2p5_inhouse_57 || in_array($source2['planets'][5]['in_house_id'], [5, 7])))
                )
            )
        )
        {
            $result[] = 1;
        }
        /**
         * 机遇
         *  该年3月1号，10月1号，其中一日的三限有日木相位（涉及三限的都检测这两天）
         */
        $is_tp_phase05_31 = isset($source1['planets'][0]['phase']['0-5']);
        $is_tp_phase05_101 = isset($source2['planets'][0]['phase']['0-5']);

        $replace_word = [
            1 => [
                1 => 35,
                2 => 36,
                3 => 37,
                4 => 38,
                5 => 39,
                6 => 40,
                7 => 41,
                8 => 42,
                9 => 43,
                10 => 44,
                11 => 45,
                12 => 46,
            ],
            2 => [
                1 => 47,
                2 => 48,
                3 => 49,
                4 => 50,
                5 => 51,
                6 => 52,
                7 => 53,
                8 => 54,
                9 => 55,
                10 => 56,
                11 => 57,
                12 => 58,
            ],
            3 => [
                1 => 59,
                2 => 60,
                3 => 61,
                4 => 62,
                5 => 63,
                6 => 64,
                7 => 65,
                8 => 66,
                9 => 67,
                10 => 68,
                11 => 69,
                12 => 70,
            ],
        ];
        // 只有3月份有
        if ($is_tp_phase05_31 && !$is_tp_phase05_101)
        {
            $p5_house = $source1['planets'][5]['in_house_id'];
            $result[] = $replace_word[1][$p5_house];
        }// 只有十月有
        elseif (!$is_tp_phase05_31 && $is_tp_phase05_101)
        {
            $p5_house = $source2['planets'][5]['in_house_id'];
            $result[] = $replace_word[2][$p5_house];
        }// 两天都有
        else
        {
            $p5_house = $source1['planets'][5]['in_house_id'];
            $result[] = $replace_word[3][$p5_house];
        }

        /**
         * 贵人
         *  三限太阳与金木同时成相，或八字流年为以下情形：天干比肩+地支正官，天干比肩+地支贵人，天干正官+地支日禄，天干正官+地支财星，天干财星+地支正官
         * 20181228
         * 1。三限太阳与金木同时成相，或，三限木星在7宫与太阳或金星合拱六分
         * 2。八字流年为以下情形：天干比肩+地支正官，天干比肩+地支贵人，天干正官+地支日禄，天干正官+地支财星，天干财星+地支正官
         *  正官受伤大于0小于1
         *  正官未受伤
         */
        // 三限太阳与金木同时成相，或，三限木星在7宫与太阳或金星合拱六分
        if (
            (isset($source1['planets'][0]['phase']['0-3'])
                && (isset($source1['planets'][0]['phase']['0-5'])
                    || isset($source2['planets'][0]['phase']['0-5'])))
            || (isset($source1['planets'][0]['phase']['0-5'])
                && (isset($source1['planets'][0]['phase']['0-3'])
                    || isset($source2['planets'][0]['phase']['0-3'])))
            ||
            ($source1['planets'][5]['in_house_id'] == 7
                && checkPhase([5], [0, 3], [0, 60, 120], $source1['planets']))
            ||
            ($source2['planets'][5]['in_house_id'] == 7
                && checkPhase([5], [0, 3], [0, 60, 120], $source2['planets']))
        )
        {
            $result[] = 71;
        }// 八字流年为以下情形：天干比肩+地支正官，天干比肩+地支贵人，天干正官+地支日禄，天干正官+地支财星，天干财星+地支正官
        elseif (($this->param['shishen'][$liu[0]][$rigan] === '比肩'
                && ($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] === '正官'
                    || $this->is_tianyiguiren($rigan, $liu[1])))
            ||
            (in_array($this->param['shishen'][$liu[0]][$rigan], ['正财', '偏财'], true)
                && $this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan] === '正官')
            ||
            ($this->param['shishen'][$liu[0]][$rigan] === '正官'
                && (
                    in_array($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan], ['正财', '偏财'])
                    || $this->is_lushen($rigan, $liu[1]))))
        {
            // 正官受伤大于0小于1
            if ($shangshen['正官'] > 0 && $shangshen['正官'] < 1)
            {
                $result[] = 72;
            } // 正官未受伤
            elseif ($shangshen['正官'] <= 0)
            {
                $result[] = 73;
            }
        }

        /**
         * 旅行
         * 三限水木成非刑相，或日木成相且其一在3/9宫
         */
        if (
            (
                isset($source1['planets'][2]['phase']['2-5'])
                && $source1['planets'][2]['phase']['2-5']['phase_e'] != 90
                && isset($source1['planets'][0]['phase']['0-5'])
                && (in_array($source1['planets'][0]['in_house_id'], [3, 9])
                    || in_array($source1['planets'][5]['in_house_id'], [3, 9]))
            )
            ||
            (
                isset($source2['planets'][2]['phase']['2-5'])
                && $source2['planets'][2]['phase']['2-5']['phase_e'] != 90
                && isset($source2['planets'][0]['phase']['0-5'])
                && (in_array($source2['planets'][0]['in_house_id'], [3, 9])
                    || in_array($source2['planets'][5]['in_house_id'], [3, 9]))
            )
        )
        {
            $result[] = 30;
        }

        /**
         * 迁移变动
         * 八字印星动且高于0.5，同时三限有3/9宫的对冲并有木星或天王参与
         */
        $is_tp_57_house39_180 = false;
        if (in_array($source1['planets'][5]['in_house_id'], [3, 9])
            && !empty($source1['planets'][5]['phase']))
        {
            foreach ($source1['planets'][5]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($is_tp_57_house39_180 === false &&
            in_array($source1['planets'][7]['in_house_id'], [3, 9])
            && !empty($source1['planets'][7]['phase']))
        {
            foreach ($source1['planets'][7]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($is_tp_57_house39_180 === false &&
            in_array($source2['planets'][5]['in_house_id'], [3, 9])
            && !empty($source2['planets'][5]['phase']))
        {
            foreach ($source2['planets'][5]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($is_tp_57_house39_180 === false &&
            in_array($source2['planets'][7]['in_house_id'], [3, 9])
            && !empty($source2['planets'][7]['phase']))
        {
            foreach ($source2['planets'][7]['phase'] as $phase)
            {
                if ($phase['phase_e'] == 180)
                {
                    $is_tp_57_house39_180 = true;
                }
            }
        }
        if ($dongshen['正印'] + $dongshen['偏印'] > 0 && $is_tp_57_house39_180)
        {
            $result[] = 31;
        }


        /**
         * 福缘 33
         * 三限木星在1宫或10宫，且火土海冥不与太阳成相不合轴不在1宫10宫
         * 三限金木成合拱六分相，且金星不与土星刑冲
         * 1.（检测该年7月1号三限）三限木星在1宫或10宫，且火土海冥不与太阳成相不合轴不在1宫10宫
         * 2.（检测该年7月1号三限）限金木成合拱六分相，且金星、太阳不与土星刑冲且2宫无土星
         */
        // （检测该年7月1号三限）三限木星在1宫或10宫，且火土海冥不与太阳成相不合轴不在1宫10宫
        if (!checkSignHouse([5], [1, 10], $source3['planets'])
            && !checkPhase([4, 6, 8, 9], [0], [], $source3['planets'])
            && checkSignHouse([4, 6, 8, 9], [1, 10], $source3['planets'])
            && checkPhase([4, 6, 8, 9], [ASC, MC], [0, 180], $source3['planets']))
        {
            $result[] = 74;
        } // （检测该年7月1号三限）限金木成合拱六分相，且金星、太阳不与土星刑冲且2宫无土星
        elseif (checkPhase([3], [5], [0, 60, 120], $source3['planets'])
            && !checkPhase([0, 3], [6], [90, 180], $source3['planets'])
            && $source3['planets'][6]['in_house_id'] != 2)
        {
            $result[] = 75;
        }


        /**
         * 学识 34
         * 三限木星在3宫，或水木成非刑相，同时八字流年干支（本气）有正偏印或食神伤官之一
         * （检测该年7月1号三限）三限木星在3宫，或水木成非刑相，且水海不成刑冲合，同时八字流年干支（本气）有正偏印或食神伤官之一
         */
        if (
            ($source3['planets'][5]['in_house_id'] == 3
                ||
                (checkPhase([2], [5], [0, 60, 120, 180], $source3['planets'])
                    && !checkPhase([2], [8], [0, 90, 180], $source3['planets'])))
            ||
            (
                in_array($liugan_shishen, ['正印', '偏印', '食神', '伤官'])
                || in_array($liuzhi_shishen, ['正印', '偏印', '食神', '伤官'])
            )
        )
        {
            $result[] = 34;
        }

        /**
         * 检测日宫是否动
         */
        if ($donggong[2] > 0)
        {
            // 夫妻星动
            $is_fuqixing_dong = false;
            // 检测夫妻星 男命 财星  女命 官杀
            $fuqixing = [];
            if ($this->option['recode']['type'] == 1)
            {
                if ($dongshen['正财'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '正财';
                }
                if ($dongshen['偏财'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '偏财';
                }
            } else
            {
                if ($dongshen['正官'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '正官';
                }
                if ($dongshen['七杀'] > 0)
                {
                    $is_fuqixing_dong = true;
                    $fuqixing[] = '七杀';
                }
            }
            // 日宫受伤且夫妻星（男财女官杀）动
            if ($shanggong[2] >= 1 && $is_fuqixing_dong)
            {
                //日支是辰戌丑未且大运流年对其无穿，或，日支不受大运流年刑穿
                if ((
                        in_array($bazi[6], ['辰', '戌', '丑', '未'])
                        && !$this->is_liuhai($liu[1], $bazi[6])
                        && ($dayun != null && !$this->is_liuhai($liu[1], $dayun[1])))
                    || (!$this->is_liuhai($liu[1], $bazi[6]) && !$this->is_xing($liu[1], $bazi[6])
                        && ($dayun != null
                            && !$this->is_liuhai($dayun[1], $bazi[6])
                            && !$this->is_xing($dayun[1], $bazi[6]))))
                {
                    $is_low = false;
                    foreach ($fuqixing as $fqx)
                    {
                        if ($shangshen[$fqx] < 0.7)
                        {
                            $is_low = true;
                        }
                    }
                    // 婚恋1
                    if ($is_low === true)
                    {
                        $result[] = 2;
                    }// 情感问题
                    else
                    {
                        $result[] = 3;
                    }
                } else
                {
                    // 情感伤害 女，本命官杀五行超过40%，流年干支有七杀，且流支有刑冲穿
                    if ($this->option['recode']['type'] != 1 && $shishen_wuxing['官杀'] >= 40
                        && ($liugan_shishen == '七杀' || $liuzhi_shishen == '七杀')
                        && (
                            $this->is_xing($liu[1], $bazi[2])
                            || $this->is_liuchong($liu[1], $bazi[2])
                            || $this->is_liuhai($liu[1], $bazi[2])
                            || $this->is_xing($liu[1], $bazi[4])
                            || $this->is_liuchong($liu[1], $bazi[4])
                            || $this->is_liuhai($liu[1], $bazi[4])
                            || $this->is_xing($liu[1], $bazi[6])
                            || $this->is_liuchong($liu[1], $bazi[6])
                            || $this->is_liuhai($liu[1], $bazi[6])
                            || $this->is_xing($liu[1], $bazi[8])
                            || $this->is_liuchong($liu[1], $bazi[8])
                            || $this->is_liuhai($liu[1], $bazi[8])
                            || (
                                $dayun != null
                                && (
                                    $this->is_xing($liu[1], $dayun[1])
                                    || $this->is_liuchong($liu[1], $dayun[1])
                                    || $this->is_liuhai($liu[1], $dayun[1])
                                )
                            )
                        )
                    )
                    {
                        $result[] = 4;
                    } // 过路桃花 本命夫妻星五行为0%，大运也无夫妻星（包括藏干）
                    elseif (
                        ($this->option['recode']['type'] == 1 && $shishen_wuxing['财'] == 0
                            && (
                                $dayun == null
                                || (
                                    !in_array($this->param['shishen'][$dayun[0]][$rigan], ['正财', '偏财'])
                                    && !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正财', '偏财'])
                                )
                            )
                        )
                        ||
                        ($this->option['recode']['type'] == 1 && $shishen_wuxing['官杀'] == 0
                            && (
                                $dayun == null
                                || (
                                    !in_array($this->param['shishen'][$dayun[0]][$rigan], ['正官', '七杀'])
                                    && !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正官', '七杀'])
                                )
                            )
                        )
                    )
                    {
                        $result[] = 5;
                    } // 过路桃花 女，本命食伤超过50%且大运地支不是官杀，或男，本命比劫超过50%且大运地支不是财星
                    elseif (
                        ($this->option['recode']['type'] != 1 && $shishen_wuxing['食伤'] >= 50
                            && ($dayun == null || !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正官', '七杀'])))
                        ||
                        ($this->option['recode']['type'] == 1 && $shishen_wuxing['比劫'] >= 50
                            && ($dayun == null || !in_array($this->param['shishen'][$dayun_benqi][$rigan], ['正财', '偏财'])))
                    )
                    {
                        $result[] = 5;
                    } // 情感问题 其它
                    else
                    {
                        $result[] = 3;
                    }
                }
            }// 日宫不受伤且夫妻星动
            elseif ($shanggong[2] < 1 && $is_fuqixing_dong)
            {
                // 婚恋2 印星动
                if ($dongshen['正印'] > 0 || $dongshen['偏印'] > 0)
                {
                    $result[] = 6;
                }// 印星不动
                else
                {
                    $result[] = 1;
                }
            }
        }

        /**
         * 检测流年是否有官杀
         */
        if (in_array($liugan_shishen, ['正官', '七杀']) || in_array($liuzhi_shishen, ['正官', '七杀']))
        {
            // 正官（官杀都有按流干算）
            if (($liuzhi_shishen == '正官' && $liugan_shishen == '七杀') || ($liuzhi_shishen == '七杀' && $liugan_shishen == '正官')
                || (in_array($liugan_shishen, ['正官', '七杀']) && !in_array($liuzhi_shishen, ['正官', '七杀'])))
            {
                $shishen_temp1 = $liugan_shishen;
                $shishen_temp2 = $liuzhi_shishen;
                $main = $liu[0];
            } else
            {
                $shishen_temp1 = $liuzhi_shishen;
                $shishen_temp2 = $liugan_shishen;
                $main = $liu_benqi;
            }
            if ($shishen_temp1 == '正官')
            {
                // 流年另一干支是不是伤官
                if ($shishen_temp2 == '伤官')
                {
                    // 升职 流干/支 伤官被合
                    if ($this->is_wuhe($main, $bazi[1])
                        || $this->is_wuhe($main, $bazi[3])
                        || $this->is_wuhe($main, $bazi[5])
                        || $this->is_wuhe($main, $bazi[7])
                        || ($dayun != null && $this->is_wuhe($main, $dayun[0]))
                    )
                    {
                        $result[] = 7;
                    }// 事业挫折
                    else
                    {
                        $result[] = 8;
                    }
                } else
                {
                    // 流年另一干支是否财或比肩
                    if (in_array($shishen_temp2, ['正财', '偏财', '比肩']))
                    {
                        // 20190104 增加一步判断：流年是否与命运某柱双冲且该柱干支之一是伤官，是的话不是升职，而是事业调整
                        if (
                            (
                                $this->is_shuangchong($liu, [[$bazi[1], $bazi[2]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[1]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->is_shuangchong($liu, [[$bazi[3], $bazi[4]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[3]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->is_shuangchong($liu, [[$bazi[5], $bazi[6]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[5]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->is_shuangchong($liu, [[$bazi[7], $bazi[8]]])
                                &&
                                (
                                    $this->param['shishen'][$bazi[7]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan]
                                )
                            )
                            ||
                            (
                                $this->data['dayun_now'] != null
                                && $this->is_shuangchong($liu, [$this->data['dayun_now']])
                                &&
                                (
                                    $this->param['shishen'][$this->data['dayun_now'][0]][$rigan]
                                    || $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan]
                                )
                            )
                        )
                        {
                            $result[] = 9;
                        } // 否则  升职
                        else
                        {
                            $result[] = 7;
                        }
                    } else
                    {
                        // 正官是否受伤
                        // 事业挫折
                        if ($shangshen['正官'] > 0.6)
                        {
                            $result[] = 8;
                        } // 事业调整
                        elseif ($shangshen['正官'] > 0)
                        {
                            $result[] = 9;
                        } // 升职
                        elseif ($shangshen['正官'] == 0)
                        {
                            $result[] = 7;
                        }
                    }
                }
            }//  七杀（官杀都有按流干算）
            else
            {
                // 本命比劫+印星+食伤比例超过50%
                if ($shishen_wuxing['比劫'] + $shishen_wuxing['印'] + $shishen_wuxing['食伤'] >= 50)
                {
                    // 奔走 流支或运支七杀与日干禄冲
                    if (
                        ($liuzhi_shishen == '七杀'
                            &&
                            (
                                ($this->is_liuchong($liu[1], $bazi[2]) && $this->is_lushen($rigan, $bazi[2]))
                                || ($this->is_liuchong($liu[1], $bazi[4]) && $this->is_lushen($rigan, $bazi[4]))
                                || ($this->is_liuchong($liu[1], $bazi[6]) && $this->is_lushen($rigan, $bazi[6]))
                                || ($this->is_liuchong($liu[1], $bazi[8]) && $this->is_lushen($rigan, $bazi[8]))
                            )
                        )
                        ||
                        ($dayun != null && $this->param['shishen'][$dayun_benqi][$rigan] == '七杀'
                            &&
                            (
                                ($this->is_liuchong($dayun[1], $bazi[2]) && $this->is_lushen($rigan, $bazi[2]))
                                || ($this->is_liuchong($dayun[1], $bazi[4]) && $this->is_lushen($rigan, $bazi[4]))
                                || ($this->is_liuchong($dayun[1], $bazi[6]) && $this->is_lushen($rigan, $bazi[6]))
                                || ($this->is_liuchong($dayun[1], $bazi[8]) && $this->is_lushen($rigan, $bazi[8]))
                            )
                        )
                    )
                    {
                        $result[] = 10;
                    }// 创业
                    else
                    {
                        $result[] = 11;
                    }
                } // 创业 流干是七杀命运天干有食神 ，或 流干七杀被命运天干合
                elseif ($liugan_shishen == '七杀'
                    &&
                    (
                        (
                            $this->param['shishen'][$bazi[1]][$rigan] == '食神'
                            || $this->param['shishen'][$bazi[3]][$rigan] == '食神'
                            || $this->param['shishen'][$bazi[7]][$rigan] == '食神'
                            || ($dayun != null
                                && $this->param['shishen'][$dayun[0]][$rigan] == '食神')
                        )
                        ||
                        (
                            $this->is_wuhe($liu[0], $bazi[1])
                            || $this->is_wuhe($liu[0], $bazi[3])
                            || $this->is_wuhe($liu[0], $bazi[5])
                            || $this->is_wuhe($liu[0], $bazi[6])
                            || ($dayun != null && $this->is_wuhe($liu[0], $dayun[0]))
                        )
                    )
                )
                {
                    $result[] = 11;
                } // 创业 命运天干有七杀，流干食神或流干合七杀
                elseif (
                    (
                        $this->param['shishen'][$bazi[1]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($bazi[1], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                    ||
                    (
                        $this->param['shishen'][$bazi[3]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($bazi[3], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                    ||
                    (
                        $this->param['shishen'][$bazi[7]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($bazi[7], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                    ||
                    (
                        $dayun != null
                        && $this->param['shishen'][$dayun[0]][$rigan] == '七杀'
                        &&
                        (
                            $this->is_wuhe($dayun[0], $liu[0])
                            || $this->param['shishen'][$liu[0]][$rigan] == '食神'
                        )
                    )
                )
                {
                    $result[] = 11;
                }
            }
        } // 检测官杀是否动
        else
        {
            // 官动
            if ($dongshen['正官'] > 0)
            {
                // 事业挫折
                if ($shangshen['正官'] > 0.6)
                {
                    $result[] = 8;
                } // 事业调整
                elseif ($shangshen['正官'] > 0)
                {
                    $result[] = 9;
                } // 升职
                elseif ($shangshen['正官'] == 0)
                {
                    $result[] = 7;
                }
            }// 杀动
            elseif ($dongshen['七杀'] > 0)
            {
                // 本命天干或日支有食神或正印，或官杀旺度低于30%
                // 创业
                if (
                    in_array($this->param['shishen'][$bazi[1]][$rigan], ['食神', '正印'])
                    || in_array($this->param['shishen'][$bazi[3]][$rigan], ['食神', '正印'])
                    || in_array($this->param['shishen'][$bazi[7]][$rigan], ['食神', '正印'])
                    || in_array($this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan], ['食神', '正印'])
                    || $shishen_wuxing['官杀'] < 30
                )
                {
                    $result[] = 11;
                } // 意外
                else
                {
                    $result[] = 12;
                }
            }
        }

        /**
         * 检测流年是否有财星，或是否财星动
         */
        if (in_array($liugan_shishen, ['正财', '偏财'])
            || in_array($liuzhi_shishen, ['正财', '偏财'])
            || $dongshen['正财'] > 0
            || $dongshen['偏财'] > 0)
        {
            // 正财（正偏都有按偏财算）
            if (($liuzhi_shishen == '正财' && $liugan_shishen == '偏财') || ($liuzhi_shishen == '偏财' && $liugan_shishen == '正财')
                || (in_array($liugan_shishen, ['正财', '偏财']) && !in_array($liuzhi_shishen, ['正财', '偏财'])))
            {
                $shishen_temp1 = $liugan_shishen;
//                $shishen_temp2 = $liuzhi_shishen;
//                $main = $liu[0];
            } else
            {
                $shishen_temp1 = $liuzhi_shishen;
//                $shishen_temp2 = $liugan_shishen;
//                $main = $liu_benqi;
            }

            if ($shishen_temp1 == '正财')
            {
                // 财来财去 流干为财，运干比劫
                if (in_array($liugan_shishen, ['正财', '偏财'])
                    && ($dayun != null
                        && in_array($this->param['shishen'][$dayun[0]][$rigan], ['比肩', '劫财'])))
                {
                    $result[] = 13;
                } //
                else
                {
                    // 财是否受伤
                    // 耗财
                    if ($shangshen['正财'] + $shangshen['偏财'] > 0.6)
                    {
                        $result[] = 14;
                    } // 财来财去
                    elseif ($shangshen['正财'] + $shangshen['偏财'] > 0)
                    {
                        $result[] = 13;
                    } // 进财
                    elseif ($shangshen['正财'] + $shangshen['偏财'] == 0)
                    {
                        $result[] = 15;
                    }
                }
            }// 偏财
            else
            {
                // 财来财去 流干为财，运干比劫
                if (in_array($liugan_shishen, ['正财', '偏财'])
                    && ($dayun != null
                        && in_array($this->param['shishen'][$dayun[0]][$rigan], ['比肩', '劫财'])))
                {
                    $result[] = 16;
                } //
                else
                {
                    // 财是否受伤
                    // 耗财
                    if ($shangshen['正财'] + $shangshen['偏财'] > 0.6)
                    {
                        $result[] = 17;
                    } // 财来财去
                    elseif ($shangshen['正财'] + $shangshen['偏财'] > 0)
                    {
                        $result[] = 16;
                    } // 进财
                    elseif ($shangshen['正财'] + $shangshen['偏财'] == 0)
                    {
                        $result[] = 18;
                    }
                }
            }
        }

        /**
         * 印星主神或印动指数高于0.4
         */
        if (in_array('正印', $this->data['liunianzhushen'])
            || in_array('偏印', $this->data['liunianzhushen'])
            || $dongshen['正印'] + $dongshen['偏印'] > 0.4
        )
        {
            // 正印受伤高于0.5
            if ($shangshen['正印'] > 0)
            {
                $result[] = 19;
            } elseif ($shangshen['正印'] < 0.5
                && !in_array($liugan_shishen, ['正财', '偏财'])
                && !in_array($liuzhi_shishen, ['正财', '偏财'])
            )
            {
                $result[] = 20;
            }
        }

        /**
         * 检测年宫是否动
         */
        if ($donggong[1] > 0)
        {
            $shangshen_cai = $shangshen['正财'] + $shangshen['偏财'];
            $shangshen_yin = $shangshen['正印'] + $shangshen['偏印'];
            // 年宫是否受伤（流年）
            if ($shanggong[0] > 0)
            {
                // 财印是否受伤
                // 父亲健康  财受伤高于印
                if ($shangshen_cai > $shangshen_yin)
                {
                    $result[] = 21;
                }// 母亲健康 印高于财
                elseif ($shangshen_yin > $shangshen_cai)
                {
                    $result[] = 22;
                } // 都无
                else
                {
                    // 财印是否在流干
                    // 父亲健康 财
                    if (in_array($liugan_shishen, ['正财', '偏财']))
                    {
                        $result[] = 21;
                    }// 母亲健康 印
                    elseif (in_array($liugan_shishen, ['正印', '正印']))
                    {
                        $result[] = 22;
                    }// 否
                    else
                    {
                        // 年宫受伤度高于1
                        if ($shanggong[0] > 1)
                        {
                            $result[] = 23;
                        }
                    }
                }
            } else
            {
                // 财印是否受伤
                // 父亲健康  财受伤高于印且高于1
                if ($shangshen_cai > $shangshen_yin && $shangshen_cai >= 1)
                {
                    $result[] = 21;
                }// 母亲健康  印受伤高于财且高于1
                elseif ($shangshen_yin > $shangshen_cai && $shangshen_yin >= 1)
                {
                    $result[] = 22;
                }
            }
        }

        /**
         * 16岁以上45岁以下，检测时宫是否动
         */
        $yearsold = $this->option['advance']['year'] - $this->option['recode']['year'];
        if ($yearsold > 16 && $yearsold < 45 && $donggong[3] > 0)
        {
            // 子女星（男官杀，女食伤）是否动
            if (($this->option['recode']['type'] == 1 && $dongshen['正官'] + $dongshen['七杀'] > 0)
                || ($this->option['recode']['type'] != 1 && $dongshen['食神'] + $dongshen['伤官'] > 0))
            {
                // 子女问题 男  星/宫在流年同时受伤
                if ($this->option['recode']['type'] == 1 && $shanggong[3] > 0 && $shangshen['正官'] + $shangshen['七杀'] > 0)
                {
                    $result[] = 25;
                }// 孕育问题 女  星/宫在流年同时受伤
                elseif ($this->option['recode']['type'] != 1 && $shanggong[3] > 0 && $shangshen['食神'] + $shangshen['伤官'] > 0)
                {
                    $result[] = 24;
                }
                // 女食神男正官在流年受伤高于1
                // 子女问题
                elseif ($this->option['recode']['type'] == 1 && $shangshen['正官'] > 1)
                {
                    $result[] = 25;
                } // 孕育问题
                elseif ($this->option['recode']['type'] != 1 && $shangshen['食神'] > 1)
                {
                    $result[] = 24;
                } // 其它
                else
                {
                    // 子女1 子女星动指数高于0.5
                    if (
                        ($this->option['recode']['type'] == 1 && $dongshen['正官'] + $dongshen['七杀'] > 0)
                        || ($this->option['recode']['type'] != 1 && $dongshen['食神'] + $dongshen['食神'] > 0)
                    )
                    {
                        $result[] = 26;
                    }// 子女2 低于0.5
                    else
                    {
                        $result[] = 27;
                    }
                }
            }
        }

        /**
         * 疾病
         *  流年有七杀或伤官，且日干禄或日支在流年受伤高于0.5
         */
        if (
            (in_array($this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan], ['七杀', '伤官'])
                || in_array($this->param['shishen'][$liu[0]][$rigan], ['七杀', '伤官']))
            &&
            (
                ($this->is_lushen($rigan, $bazi[2])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[2]][0]][$rigan]] >= 0.5)
                || ($this->is_lushen($rigan, $bazi[4])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[4]][0]][$rigan]] >= 0.5)
                || ($this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[6]][0]][$rigan]] >= 0.5)
                || ($this->is_lushen($rigan, $bazi[8])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$bazi[8]][0]][$rigan]] >= 0.5)
                || ($this->is_lushen($rigan, $liu[1])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$liu[1]][0]][$rigan]] >= 0.5)
                || ($this->data['dayun_now'] != null
                    && $this->is_lushen($rigan, $this->data['dayun_now'][1])
                    && $this->data['shangshen'][$this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan]] >= 0.5))
        )
        {
            $result[] = 32;
        }

        return array_unique($result);
    }

    /**
     * 获取用户八字数据
     * @return array
     */
    public function getUserData()
    {
        $this->option['liunian_realtime'] = true;
        $this->getAllData();

        $return = [
            'birth_time' => date('Y.m.d H:i', $this->data['birth_time']),
            'sex' => $this->option['recode']['type'],
            'bazi' => $this->data['bazi'],
        ];
        $shishen = $this->getShishen();
        $shishen1 = [
            $this->shishenToEasy($shishen['gan'][1]['relation']),
            $this->shishenToEasy($shishen['gan'][3]['relation']),
            '日元',
            $this->shishenToEasy($shishen['gan'][7]['relation']),
        ];
        $shishen2 = [];
        foreach ($shishen['cang'] as $k => $cang)
        {
            $shishen2[$k] = '';
            foreach ($cang as $cg)
            {
                $shishen2[$k] .= $this->shishenToEasy($cg['relation']);
            }
        }
        // 食神关系
        $return['shishen1'] = $shishen1;
        $return['shishen2'] = array_values($shishen2);
        //  藏干
        $return['canggan'] = [
            $this->param['canggan'][$this->data['bazi'][2]],
            $this->param['canggan'][$this->data['bazi'][4]],
            $this->param['canggan'][$this->data['bazi'][6]],
            $this->param['canggan'][$this->data['bazi'][8]],
        ];

        // 长生十二宫
        $return['changsheng'] = [
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][2]],
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][4]],
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][6]],
            $this->param['changsheng'][$this->data['bazi'][5]][$this->data['bazi'][8]],
        ];
        // 纳音关系
        $return['nayin'] = [
            $this->getNayin($this->data['bazi'][1], $this->data['bazi'][2]),
            $this->getNayin($this->data['bazi'][3], $this->data['bazi'][4]),
            $this->getNayin($this->data['bazi'][5], $this->data['bazi'][6]),
            $this->getNayin($this->data['bazi'][7], $this->data['bazi'][8]),
        ];
        // 空亡
        $return['kongwang'] = [
            $this->getKongwang($this->data['bazi'][1], $this->data['bazi'][2]),
            $this->getKongwang($this->data['bazi'][3], $this->data['bazi'][4]),
            $this->getKongwang($this->data['bazi'][5], $this->data['bazi'][6]),
            $this->getKongwang($this->data['bazi'][7], $this->data['bazi'][8]),
        ];

        $this->getWuxingPercent();
        $return['wuxing'] = $this->data['wuxing_perc'];
        $return['start_time'] = date('Y.m.d', $this->data['st_time']);
        $return['start_year_old'] = sprintf('%.1f', abs($this->data['st_time'] - $this->data['birth_time']) / (3600 * 24 * 365)) * 1;
        $return['geju'] = $this->getStructure();

        $nowYear = (int)(date('Y'));
        // 大运
        $st_year = (int)(date('Y', $this->data['st_time']));// 大运起
        $num = 0;
        // 初始化大运状态和流年状态为未开始 [-1已过去｜0进行中｜1未开始]
        $d_status = $l_status = -1;
        for ($j = $st_year; $j <= $st_year + 50; $j += 10)
        {
            /**
             * 若当前大运状态为未开始，且当前年份在循环的大运年范围内，则标记当前大运年为进行中
             * 或 当前时间尚未立春，则-1年
             */
            if ($d_status === -1 && $nowYear >= $j
                && ($nowYear < $j + 10 || ($this->data['liunian_lichun'] === false && $nowYear < $j + 11)))
            {
                $d_status = 0;
            }// 若大运起始年份比当前年份大 或 当前在大运年范围内且当前年份小于循环的年份   则标记大运年状态为未开始
            elseif ($st_year > $nowYear || ($d_status === 0 && $nowYear < $j))
            {
                $d_status = 1;
            }
            // 八字流年表第一行数据 大运干支与状态
            $return['dayun'][0][] = ['name' => $this->data['dayun'][$num], 'status' => $d_status];
            // 八字流年表第二行数据 大运的开始时间与状态
            $return['dayun'][1][] = ['name' => $j, 'status' => $d_status];

            // 八字流年表第N行数据
            $s = 2;
            // 流年数据
            for ($i = $j; $i < $j + 10; $i++)
            {
                // 该年干支
                $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($i)];
                // 若流年状态为已过去 且 大运状态为进行中 且 该年干支与流年干支一致 则标记当前流年状态为进行中
                if ($l_status === -1 && $d_status === 0 && $y_gan_zhi === $this->data['liunian_now'][0] . $this->data['liunian_now'][1])
                {
                    $l_status = 0;
                }// 若流年状态为进行中 或  循环的年份大于当前年份 则标记当前流年状态为未开始
                elseif ($l_status === 0 || $j > $nowYear)
                {
                    $l_status = 1;
                }
                // 八字流年表第N行数据 大运的干支与状态
                $return['dayun'][$s][] = ['name' => $y_gan_zhi, 'status' => $l_status];
                $s++;
            }
            // 八字流年表第12行数据 大运的结束时间与状态
            $return['dayun'][12][] = ['name' => $i - 1, 'status' => $d_status];
            $num++;
        }

        return $return;
    }

    public function getUserData2()
    {
        $this->option['liunian_realtime'] = true;
        $this->getAllData();
        $return = [
            'birth_time' => date('Y.m.d H:i', $this->data['birth_time']),
            'sex' => $this->option['recode']['type'],
            'bazi' => $this->data['bazi'],
        ];
        $shishen = $this->getShishen();
        $shishen1 = [
            $this->shishenToEasy($shishen['gan'][1]['relation']),
            $this->shishenToEasy($shishen['gan'][3]['relation']),
            '日元',
            $this->shishenToEasy($shishen['gan'][7]['relation']),
        ];
        $shishen2 = [];
        foreach ($shishen['cang'] as $k => $cang)
        {
            $shishen2[$k] = '';
            foreach ($cang as $cg)
            {
                $shishen2[$k] .= $this->shishenToEasy($cg['relation']);
            }
        }
        // 食神关系
        $return['shishen1'] = $shishen1;
        $return['shishen2'] = array_values($shishen2);
        //  藏干
        $return['canggan'] = [
            $this->param['canggan'][$this->data['bazi'][2]],
            $this->param['canggan'][$this->data['bazi'][4]],
            $this->param['canggan'][$this->data['bazi'][6]],
            $this->param['canggan'][$this->data['bazi'][8]],
        ];
        $nowYear = (int)(date('Y'));
        // 大运
        $st_year = (int)(date('Y', $this->data['st_time']));// 大运起
        $num = 0;
        // 初始化大运状态和流年状态为未开始 [-1已过去｜0进行中｜1未开始]
        $d_status = $l_status = -1;

        for ($j = $st_year; $j <= $st_year + 90; $j += 10)
        {
            /**
             * 若当前大运状态为未开始，且当前年份在循环的大运年范围内，则标记当前大运年为进行中
             * 或 当前时间尚未立春，则-1年
             */
            if ($d_status === -1 && $nowYear >= $j
                && ($nowYear < $j + 10 || ($this->data['liunian_lichun'] === false && $nowYear < $j + 11)))
            {
                $d_status = 0;
            }// 若大运起始年份比当前年份大 或 当前在大运年范围内且当前年份小于循环的年份   则标记大运年状态为未开始
            elseif ($st_year > $nowYear || ($d_status === 0 && $nowYear < $j))
            {
                $d_status = 1;
            }
            // 八字流年表第一行数据 大运干支与状态
            $return['dayun'][] = ['name' => $this->data['dayun'][$num], 'status' => $d_status, 'start_year' => $j, 'end_year' => $j + 9];
            // 八字流年表第N行数据
            $s = 0;
            // 流年数据
            for ($i = $j; $i < $j + 10; $i++)
            {
                // 该年干支
                $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($i)];
                // 若流年状态为已过去 且 大运状态为进行中 且 该年干支与流年干支一致 则标记当前流年状态为进行中
                if ($l_status === -1 && $d_status === 0 && $y_gan_zhi === $this->data['liunian_now'][0] . $this->data['liunian_now'][1])
                {
                    $l_status = 0;
                }// 若流年状态为进行中 或  循环的年份大于当前年份 则标记当前流年状态为未开始
                elseif ($l_status === 0 || $j > $nowYear)
                {
                    $l_status = 1;
                }
                // 八字流年表第N行数据 大运的干支与状态
                $return['liunian'][$num][] = ['name' => $y_gan_zhi, 'status' => $l_status, 'year' => $i];
                $s++;
            }
            $num++;
        }
        return $return;
    }

    /**
     * 新版八字展示数据
     * @return array
     */
    public function getUserData3()
    {
        $this->option['liunian_realtime'] = true;
        $this->getAllData2();
        $bazi = $this->data['bazi'];
        $minggong = $this->baziMinggong($bazi);
        $taiyuan = $this->baziTaiyuan($bazi);

        $birthYear = date('Y', $this->data['birth_time']);
        $nowYear = (int)(date('Y'));
        // 大运
        $st_year = (int)(date('Y', $this->data['st_time']));// 大运起

        $recode = $this->option['recode'];
        $birthTime = strtotime($recode['year'] . '-' . $recode['month'] . '-' . $recode['day'] . ' ' . $recode['hour'] . ':' . $recode['minute']);
        $brithday1 = date('Y年m月d日 H:i', $birthTime);
//        $lunar = 1;
//        $nongli = (new Lunar())->GetLunar($recode['year'], $recode['month'], $recode['day'], $lunar);
        // 新 获取农历信息 -- 开始
        $nongliData = (new Calendar())->solar($recode['year'], $recode['month'], $recode['day']);
        $nongli = $nongliData['lunar_month_chinese'] . $nongliData['lunar_day_chinese'];
        // 新 获取农历信息 -- 结束
        $brithday2 = $bazi[1] . $bazi[2] . '年' . $nongli . ' ' . $bazi[8] . '时';
        $yearsOld = ceil(abs(time() - $this->data['birth_time']) / (3600 * 24 * 365));
        $qiyunNianshu = sprintf('%.1f', abs($this->data['st_time'] - $this->data['birth_time']) / (3600 * 24 * 365));
        $qiyunMiaoshu = $this->toTimeStr($this->data['st_time'], $this->data['birth_time']);
        // 起运年干支
        $qiyunGanZhi = $this->param['chinese_era'][$this->getYearStemBranche($st_year)];
        try
        {
            $qiyunStr = $qiyunMiaoshu . ' 逢' . mb_substr($qiyunGanZhi, 0, 1) . '年交运 ';
            $jiaoyunJie = (new SolarTerms())->where('time', '<', $this->data['st_time'])->order('time DESC')->find()->toArray();
            $jiaoyunName = $this->getJieQiName($jiaoyunJie['deg']);
            $dayDiff = $this->toTimeStr($jiaoyunJie['time'], $this->data['st_time'], '%d天');
            $qiyunStr .= $jiaoyunName . '后' . $dayDiff . '交大运';
        }
        catch (\Exception $e)
        {
            $qiyunStr = '';
        }

        $return = [
            // 颜色数据
            //#5BBB87 木
            //#EC8337 火
            //#C5C0C0 土
            //#FDC756 金
            //#5F7CEE 水
            'color_data' => [
                '甲' => '#379964', '乙' => '#379964',// #379964
                '丙' => '#CF6314', '丁' => '#CF6314',// #CF6314
                '戊' => '#969090', '己' => '#969090',// #969090
                '庚' => '#EAAD0B', '辛' => '#EAAD0B',// #EAAD0B
                '壬' => '#4C6CE9', '癸' => '#4C6CE9',// #4C6CE9
                '子' => '#4C6CE9', '丑' => '#969090',
                '寅' => '#379964', '卯' => '#379964',
                '辰' => '#969090', '巳' => '#CF6314',
                '午' => '#CF6314', '未' => '#969090',
                '申' => '#EAAD0B', '酉' => '#EAAD0B',
                '戌' => '#969090', '亥' => '#4C6CE9',
            ],
            // 时间
            'shijian' => [
                0 => ['年柱', date('Y', $this->data['birth_time'])],
                1 => ['月柱', date('m', $this->data['birth_time'])],
                2 => ['日柱', date('d', $this->data['birth_time'])],
                3 => ['时柱', date('H:i', $this->data['birth_time'])],
            ],
            // 十神
            'shishen' => [
                $this->param['shishen'][$bazi[1]][$bazi[5]],
                $this->param['shishen'][$bazi[3]][$bazi[5]],
                '元' . ($this->option['recode']['type'] === 1 ? '男' : '女'),
                $this->param['shishen'][$bazi[7]][$bazi[5]],
            ],
            // 天干
            'tiangan' => [
                $bazi[1],
                $bazi[3],
                $bazi[5],
                $bazi[7],
            ],
            // 地支
            'dizhi' => [
                $bazi[2],
                $bazi[4],
                $bazi[6],
                $bazi[8],
            ],
            // 藏干
            'canggan' => [],
            // 节令
            'jieling' => [
                $this->param['changsheng'][$bazi[5]][$bazi[2]],
                $this->param['changsheng'][$bazi[5]][$bazi[4]],
                $this->param['changsheng'][$bazi[5]][$bazi[6]],
                $this->param['changsheng'][$bazi[5]][$bazi[8]],
            ],
            // 纳音
            'nayin' => [
                $this->getNayin($bazi[1], $bazi[2]),
                $this->getNayin($bazi[3], $bazi[4]),
                $this->getNayin($bazi[5], $bazi[6]),
                $this->getNayin($bazi[7], $bazi[8]),
            ],
            // 空亡
            'kongwang' => [
                $this->getKongwang($bazi[1], $bazi[2]),
                $this->getKongwang($bazi[3], $bazi[4]),
                $this->getKongwang($bazi[5], $bazi[6]),
                $this->getKongwang($bazi[7], $bazi[8]),
            ],
            // 档案信息
            'recode_info' => [
                'name' => '',
                'sex_age' => [
                    ($this->option['recode']['type'] === 1 ? '男' : '女'),
                    $this->baziShengxiao($bazi[2]),
                    $yearsOld . '(虚岁)',
                ],
                // 公历
                'brithday1' => $brithday1,
                // 农历
                'brithday2' => $brithday2,
                // 起运
                'qiyun' => $qiyunStr,
                // 命宫
                'minggong' => [$minggong[0], $minggong[1], $this->getNayin($minggong[0], $minggong[1])],
                // 胎元
                'taiyuan' => [$taiyuan[0], $taiyuan[1], $this->getNayin($taiyuan[0], $taiyuan[1])],
                // 司令
                'siling' => $this->data['siling'],
            ],
            'liuyun' => [
                'dayun' => [],
                'liu_year' => [],
                'liu_month' => [],
                'start_time' => date('Y年m月d日', $this->data['st_time']) . '（' . $qiyunNianshu . '岁起运）',
            ],
            'shensha' => [],
            'guanxi' => [],
        ];
        // 遍历地支 写入藏干数据
        foreach ($return['dizhi'] as $v1)
        {
            $t = [];
            // 遍历地支藏干
            foreach ($this->param['canggan'][$v1] as $v2)
            {
                $t[] = $v2;
                $t[] = $this->shishenToEasy($this->param['shishen'][$v2][$bazi[5]]);
            }
            $return['canggan'][] = $t;
        }
        // 大运第一个是小运
        $firstYearsOld = date('Y', $this->data['st_time']) - $this->option['recode']['year'];
        $firstYearsOld = $firstYearsOld < 1 ? 1 : $firstYearsOld;
        $return['liuyun']['dayun'][] = [
            'is_select' => ($this->option['advance']['year'] >= $birthYear && $this->option['advance']['year'] < $st_year) ? 1 : 0,
//            'h1' => '<' . ($qiyunNianshu < 1 ? $qiyunNianshu : floor($qiyunNianshu)),
            'h1' => '<' . $firstYearsOld,
            'h2' => $birthYear,
            'tian_di' => ['小', '运'],
            'shishen' => [],
        ];
        // 大运起运前的小运流年数据
        $liunianXiaoyun = [];
        foreach ($this->data['xiaoyun'] as $k1 => $v1)
        {
            $isSelect = 0;
            $xiaoyunNian = $birthYear + $k1;
            // 若当前时间为小运中的某一年，则仅补充该年
            // 若当前时间尚未进入小运，则默认补充第一个
            // 若当前时间已结束所有运势，则补充最后一个大运
            if ($this->option['advance']['year'] === $xiaoyunNian || ($this->option['advance']['year'] < $birthYear && $k1 === 0))
            {
                $isSelect = 1;
            }
            // 该年干支
            $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($xiaoyunNian)];
            // 流年干支
            $ln = [mb_substr($y_gan_zhi, 0, 1), mb_substr($y_gan_zhi, 1, 1)];
            $xy = [mb_substr($v1, 0, 1), mb_substr($v1, 1, 1)];
            $xycg = $xycgss = $lncg = $lncgss = [];
            // 小运藏干
            foreach ($this->param['canggan'][$xy[1]] as $k2 => $v2)
            {
                $cgss = $this->shishenToEasy($this->param['shishen'][$v2][$bazi[5]]);
                $xycg[] = $v2;
                $xycg[] = $cgss;
            }
            // 流年藏干
            $lncgss[] = $this->shishenToEasy($this->param['shishen'][$ln[0]][$bazi[5]]);
            foreach ($this->param['canggan'][$ln[1]] as $k2 => $v2)
            {
                $cgss = $this->shishenToEasy($this->param['shishen'][$v2][$bazi[5]]);
                $lncg[] = $v2;
                $lncg[] = $cgss;
                $lncgss[] = $cgss;
            }
            $replace = [
                // 时间 (大运 + 流年)
                'shijian' => [
                    0 => ['小运', (string)$xiaoyunNian],
                    1 => ['流年', (string)$xiaoyunNian],
                ],
                // 十神 (大运 + 流年)
                'shishen' => [
                    $this->param['shishen'][$xy[0]][$bazi[5]],
                    $this->param['shishen'][$ln[0]][$bazi[5]],
                ],
                // 天干 (大运 + 流年)
                'tiangan' => [
                    $xy[0],
                    $ln[0],
                ],
                // 地支 (大运 + 流年)
                'dizhi' => [
                    $xy[1],
                    $ln[1],
                ],
                // 藏干 (大运 + 流年)
                'canggan' => [$xycg, $lncg],
                // 节令 (大运 + 流年)
                'jieling' => [
                    $this->param['changsheng'][$bazi[5]][$xy[1]],
                    $this->param['changsheng'][$bazi[5]][$ln[1]],
                ],
                // 纳音 (大运 + 流年)
                'nayin' => [
                    $this->getNayin($xy[0], $xy[1]),
                    $this->getNayin($ln[0], $ln[1]),
                ],
                // 空亡 (大运 + 流年)
                'kongwang' => [
                    $this->getKongwang($xy[0], $xy[1]),
                    $this->getKongwang($ln[0], $ln[1]),
                ],
                // 神煞信息
                'shensha' => [],
                // 关系数据
                'guanxi' => $this->baziGuanxi($bazi, $xy, $ln),
            ];
            if ($this->option['shensha'] !== 0)
            {
                $replace['shensha'] = [
                    'zizuo' => [
                        $this->param['changsheng'][$bazi[1]][$bazi[2]],
                        $this->param['changsheng'][$bazi[3]][$bazi[4]],
                        $this->param['changsheng'][$bazi[5]][$bazi[6]],
                        $this->param['changsheng'][$bazi[7]][$bazi[8]],
                        $this->param['changsheng'][$xy[0]][$xy[1]],
                        $this->param['changsheng'][$ln[0]][$ln[1]],
                    ],
                    'shensha' => $this->getShensha($bazi, $xy, $ln),
                ];
            } else
            {
                $replace['shensha'] = null;
            }
            $liunianXiaoyun[] = [
                'is_select' => $isSelect,
                'h1' => ($k1 + 1) . '岁',
                'h2' => (string)$xiaoyunNian,
                'tian_di' => $ln,
                'shishen' => $lncgss,
                'replace' => $replace,
            ];
            if ($isSelect === 1)
            {
                $return['shijian'] = array_merge($return['shijian'], $replace['shijian']);
                $return['shishen'] = array_merge($return['shishen'], $replace['shishen']);
                $return['tiangan'] = array_merge($return['tiangan'], $replace['tiangan']);
                $return['dizhi'] = array_merge($return['dizhi'], $replace['dizhi']);
                $return['canggan'] = array_merge($return['canggan'], $replace['canggan']);
                $return['jieling'] = array_merge($return['jieling'], $replace['jieling']);
                $return['nayin'] = array_merge($return['nayin'], $replace['nayin']);
                $return['kongwang'] = array_merge($return['kongwang'], $replace['kongwang']);
                // 初始化时的神煞和关系数据，此数据随着切换流年而改变
                $return['shensha'] = $replace['shensha'];
                $return['guanxi'] = $replace['guanxi'];
            }
        }
        $return['liuyun']['liu_year'][] = $liunianXiaoyun;
        // 检测是否超出展示的大运年范围
        $isChaochuDayun = false;
        if ($this->option['advance']['year'] >= $st_year + 90)
        {
            $isChaochuDayun = true;
        }
        foreach ($this->data['dayun'] as $k1 => $v1)
        {
//            $dayunNian = $birthYear + $k1;
            $dyNian = $st_year + $k1 * 10;
            $qySui = $dyNian - $birthYear;
            $qySui = $qySui === 0 ? 1 : $qySui;
            $dy = [mb_substr($v1, 0, 1), mb_substr($v1, 1, 1)];
            $dycg = $dycgss = [];
            // 小运藏干
            $dycgss[] = $this->shishenToEasy($this->param['shishen'][$dy[0]][$bazi[5]]);
            foreach ($this->param['canggan'][$dy[1]] as $k2 => $v2)
            {
                $cgss = $this->shishenToEasy($this->param['shishen'][$v2][$bazi[5]]);
                $dycg[] = $v2;
                $dycg[] = $cgss;
                $dycgss[] = $cgss;
            }
            $dayunSelect = ($this->option['advance']['year'] >= $dyNian && $this->option['advance']['year'] < $dyNian + 10) ? 1 : 0;
            if ($k1 === 8 && $isChaochuDayun)
            {
                $dayunSelect = 1;
            }
            $return['liuyun']['dayun'][] = [
                'is_select' => $dayunSelect,
                'h1' => $qySui . '岁',
                'h2' => $dyNian,
                'tian_di' => $dy,
                'shishen' => $dycgss,
            ];
            $endYear = $dyNian + 10;
            $lnData = [];
            for ($i = $dyNian; $i < $endYear; $i++)
            {
                $isSelect = 0;
                // 若当前时间等于当前小运时间，选中
                if ($this->option['advance']['year'] === $i || ($dayunSelect === 1 && $i === $endYear - 1 && $isChaochuDayun))
                {
                    $isSelect = 1;
                }
                // 该年干支
                $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($i)];
                // 流年干支
                $ln = [mb_substr($y_gan_zhi, 0, 1), mb_substr($y_gan_zhi, 1, 1)];
                // 流年藏干
                $lncg = $lncgss = [];
                $lncgss[] = $this->shishenToEasy($this->param['shishen'][$ln[0]][$bazi[5]]);
                foreach ($this->param['canggan'][$ln[1]] as $k2 => $v2)
                {
                    $cgss = $this->shishenToEasy($this->param['shishen'][$v2][$bazi[5]]);
                    $lncg[] = $v2;
                    $lncg[] = $cgss;
                    $lncgss[] = $cgss;
                }
                $replace = [
                    // 时间 (大运 + 流年)
                    'shijian' => [
                        0 => ['大运', (string)$dyNian],
                        1 => ['流年', (string)$i],
                    ],
                    // 十神 (大运 + 流年)
                    'shishen' => [
                        $this->param['shishen'][$dy[0]][$bazi[5]],
                        $this->param['shishen'][$ln[0]][$bazi[5]],
                    ],
                    // 天干 (大运 + 流年)
                    'tiangan' => [
                        $dy[0],
                        $ln[0],
                    ],
                    // 地支 (大运 + 流年)
                    'dizhi' => [
                        $dy[1],
                        $ln[1],
                    ],
                    // 藏干 (大运 + 流年)
                    'canggan' => [$dycg, $lncg],
                    // 节令 (大运 + 流年)
                    'jieling' => [
                        $this->param['changsheng'][$bazi[5]][$dy[1]],
                        $this->param['changsheng'][$bazi[5]][$ln[1]],
                    ],
                    // 纳音 (大运 + 流年)
                    'nayin' => [
                        $this->getNayin($dy[0], $dy[1]),
                        $this->getNayin($ln[0], $ln[1]),
                    ],
                    // 空亡 (大运 + 流年)
                    'kongwang' => [
                        $this->getKongwang($dy[0], $dy[1]),
                        $this->getKongwang($ln[0], $ln[1]),
                    ],
                    // 神煞信息
                    'shensha' => [],
                    // 关系数据
                    'guanxi' => $this->baziGuanxi($bazi, $dy, $ln),
                ];
                if ($this->option['shensha'] !== 0)
                {
                    $replace['shensha'] = [
                        'zizuo' => [
                            $this->param['changsheng'][$bazi[1]][$bazi[2]],
                            $this->param['changsheng'][$bazi[3]][$bazi[4]],
                            $this->param['changsheng'][$bazi[5]][$bazi[6]],
                            $this->param['changsheng'][$bazi[7]][$bazi[8]],
                            $this->param['changsheng'][$dy[0]][$dy[1]],
                            $this->param['changsheng'][$ln[0]][$ln[1]],
                        ],
                        'shensha' => $this->getShensha($bazi, $dy, $ln),
                    ];
                } else
                {
                    $replace['shensha'] = null;
                }
                $lnData[] = [
                    'is_select' => $isSelect,
                    'h1' => ($i - $birthYear) . '岁',
                    'h2' => (string)$i,
                    'tian_di' => $ln,
                    'shishen' => $lncgss,
                    'replace' => $replace,
                ];
                if ($isSelect === 1)
                {
                    $return['shijian'] = array_merge($return['shijian'], $replace['shijian']);
                    $return['shishen'] = array_merge($return['shishen'], $replace['shishen']);
                    $return['tiangan'] = array_merge($return['tiangan'], $replace['tiangan']);
                    $return['dizhi'] = array_merge($return['dizhi'], $replace['dizhi']);
                    $return['canggan'] = array_merge($return['canggan'], $replace['canggan']);
                    $return['jieling'] = array_merge($return['jieling'], $replace['jieling']);
                    $return['nayin'] = array_merge($return['nayin'], $replace['nayin']);
                    $return['kongwang'] = array_merge($return['kongwang'], $replace['kongwang']);
                    // 初始化时的神煞和关系数据，此数据随着切换流年而改变
                    $return['shensha'] = $replace['shensha'];
                    $return['guanxi'] = $replace['guanxi'];
                }
            }
            $return['liuyun']['liu_year'][] = $lnData;
        }
        // 是否需要流月信息
        if ($this->option['liuyue'])
        {
            // 解决between 写法线上查不出数据的问题，换成取大于限制N条
            $where = [
                'type' => 1,
                'time' => ['>=', strtotime($birthYear . '-01-01')],
            ];
            $limit = ($st_year + 90 - $birthYear) * 12;
            // 查询从出生年份到流年结束的所有节
            $jieList = (new SolarTerms())
                ->field('deg,time')
                ->where($where)
                ->order('time ASC')
                ->limit($limit)
                ->select();
            $jieList = json_decode(json_encode($jieList, true), true);
            $liuyue = [];
            $endYue = [];
            $n = 1;
            foreach ($jieList as $k1 => $v1)
            {
                $time = strtotime('+8 hour', $v1['time']);
                $jieYear = (int)date('Y', $time);
                // 八字中以立春论新年，若当前月份未到立春，则流年应该是上一个
                // 该年干支
                $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($jieYear)];
                // 流年干支
                $ln = [mb_substr($y_gan_zhi, 0, 1), mb_substr($y_gan_zhi, 1, 1)];
                $ganzhi = $this->getLiuyueGanzhi($ln[0], $v1['deg']);
                $yueData = [
                    'h1' => date('n/j', $time),
                    'h2' => $this->getJieQiName($v1['deg']),
                    'tian_di' => $ganzhi,
                ];
                // 未到立春，放到最后
                if ($v1['deg'] < 315 && date('n', $time) < 3)
                {
                    $endYue = $yueData;
                } else
                {
                    $liuyue[] = $yueData;
                }
                if ($n === 12)
                {
                    // 将立春之前的放在最后(八字以立春论新年)
                    $liuyue[] = $endYue;
                    // 若出生年=起运年，则直接补充到小运里面
                    if ((int)$birthYear === $st_year && $jieYear === $st_year)
                    {
                        $return['liuyun']['liu_month'][0][] = $liuyue;
                    }
                    $key = ($jieYear - $st_year);
                    /**
                     * 1993 1993
                     * 1993 1994
                     */
                    // 节令年小于起运年时
                    if ($key < 0)
                    {
                        $return['liuyun']['liu_month'][0][] = $liuyue;
                        $n = 0;
                        $liuyue = [];
                    } else
                    {
                        $key = (int)(($jieYear - $st_year) / 10) + 1;
                        $return['liuyun']['liu_month'][$key][] = $liuyue;
                        $n = 0;
                        $liuyue = [];
                    }
                }
                $n++;
            }
        }
        $return['is_need_show_tip'] = $this->data['is_need_show_tip'];
        return $return;
    }

    /**
     * 桃花
     * @return int
     */
    public function getTaohua()
    {
        $this->getAllData();
        $st_year = date('Y', $this->data['st_time']);
        for ($i = $st_year; $i < $this->option['advance']['year']; $i += 10) if ($this->option['advance']['year'] >= $i && $this->option['advance']['year'] < $i + 10) $st_year = $i;

        $d_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($st_year)];
        $d_gan = mb_substr($d_gan_zhi, 0, 1, 'utf-8');
        $d_zhi = mb_substr($d_gan_zhi, 1, 1, 'utf-8');
        $dazhi = $this->param['canggan'][$d_zhi][0];

        $taohua = 0;
        $y_gan_zhi = $this->param['chinese_era'][$this->getYearStemBranche($this->option['advance']['year'])];
        $y_gan = mb_substr($y_gan_zhi, 0, 1, 'utf-8');
        $y_zhi = mb_substr($y_gan_zhi, 1, 1, 'utf-8');
        $liuzhi = $this->param['canggan'][$y_zhi][0];
        $rizhi = $this->param['canggan'][$this->data['bazi'][6]][0];

        if (

            ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '正财'
                    || $this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '偏财'))
            ||

            ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '七杀'
                    || $this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '正官'))
        )
        {
            $taohua += 15;

            if ($this->is_lushen($this->data['bazi'][5], $y_zhi))
            {
                $taohua += 15;
            }

            if ($this->data['bazi'][6] == $y_zhi)
            {
                $taohua += 12;
            }
        }

        if (

            ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正财'
                    || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '偏财'))
            ||

            ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '七杀'
                    || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正官'))
        )
        {
            $taohua += 12;

            if ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '比肩')
            {
                $taohua += 13;
            }

            if ($this->is_liuhe($y_gan, $this->data['bazi'][5]))
            {
                $taohua += 15;
            }
        }

        if ($this->is_liuhe($y_zhi, $this->data['bazi'][6]))
        {
            $taohua += 8;

            if ($this->is_liuhe($y_gan, $this->data['bazi'][5]))
            {
                $taohua += 8;
            }

            if (

                ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正财'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '偏财'))
                ||

                ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '七杀'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正官'))
            )
            {
                $taohua += 8;
            }
        }

        if ($this->is_liuchong($y_zhi, $this->data['bazi'][6]))
        {
            if (

                ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正财'
                        || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '偏财'))
                ||

                ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '七杀'
                        || $this->param['shishen'][$liuzhi][$this->data['bazi'][5]] == '正官'))
            )
            {
                $taohua += 7;
            }
            if (

                ($this->option['recode']['type'] == 1 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正财'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '偏财'))
                ||

                ($this->option['recode']['type'] == 2 && ($this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '七杀'
                        || $this->param['shishen'][$rizhi][$this->data['bazi'][5]] == '正官'))
            )
            {
                $taohua += 7;
            }

            if ($this->param['shishen'][$y_gan][$this->data['bazi'][5]] == '比肩')
            {
                $taohua += 7;
            }

            if (
                $this->is_liuhe($this->data['bazi'][6], $this->data['bazi'][2])
                || $this->is_liuhe($this->data['bazi'][6], $this->data['bazi'][4])
                || $this->is_liuhe($this->data['bazi'][6], $this->data['bazi'][8])
            )
            {
                $taohua += 7;
            }

            if (in_array($this->data['bazi'][6], ['辰', '戌', '丑', '未']))
            {
                $taohua += 3;
            }
        }

        if ($this->is_taohua($this->data['bazi'][6], $y_zhi))
        {
            $taohua += 5;
        }

        if (
            $this->is_taohua($this->data['bazi'][2], $y_zhi)
            && (
                $this->data['bazi'][4] == $y_zhi
                || $this->data['bazi'][4] == $y_zhi
                || $this->data['bazi'][4] == $y_zhi
                || $d_zhi == $y_zhi
            )
        )
        {
            $taohua += 5;
        }

        $temp_arr = [$this->data['bazi'][2], $this->data['bazi'][4], $this->data['bazi'][6], $this->data['bazi'][8], $d_zhi];

        if (

            $this->is_liuhe($y_zhi, $this->data['bazi'][2]) &&

            ($this->is_liuchong($this->data['bazi'][2], $temp_arr) || $this->is_liuhai($this->data['bazi'][2], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][2]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][2]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $this->data['bazi'][4]) &&

            ($this->is_liuchong($this->data['bazi'][4], $temp_arr) || $this->is_liuhai($this->data['bazi'][4], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][4]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][4]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $this->data['bazi'][6]) &&

            ($this->is_liuchong($this->data['bazi'][6], $temp_arr) || $this->is_liuhai($this->data['bazi'][6], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][6]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][6]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $this->data['bazi'][8]) &&

            ($this->is_liuchong($this->data['bazi'][8], $temp_arr) || $this->is_liuhai($this->data['bazi'][8], $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][8]][0]][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][8]][0]][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        } elseif (

            $this->is_liuhe($y_zhi, $d_zhi) &&

            ($this->is_liuchong($d_zhi, $temp_arr) || $this->is_liuhai($d_zhi, $temp_arr))

        )
        {
            if (
                ($this->option['recode']['type'] == 1 &&
                    in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['偏财', '正财']))
                ||
                ($this->option['recode']['type'] == 2 &&
                    in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['七杀', '正官']))
            )
            {
                $taohua += 8;
            }
        }

        if (
            ($this->option['recode']['type'] == 1 && in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['偏财', '正财']))
            || ($this->option['recode']['type'] == 2 && in_array($this->param['shishen'][$dazhi][$this->data['bazi'][5]], ['七杀', '正官']))
        )
        {
            if ($this->is_liuhe($y_zhi, $d_zhi))
            {
                $taohua += 10;
            }
            if ($this->is_gong($y_zhi, $d_zhi))
            {
                $taohua += 7;
            }
            if ($this->is_liuchong($y_zhi, $d_zhi))
            {
                $taohua += 5;
            }
        }

        if (
            (($this->option['recode']['type'] == 1 && in_array($this->param['shishen'][$y_gan][$this->data['bazi'][5]], ['偏财', '正财']))
                || ($this->option['recode']['type'] == 2 && in_array($this->param['shishen'][$y_gan][$this->data['bazi'][5]], ['七杀', '正官'])))
            && (
                $this->is_lushen($y_gan, $this->data['bazi'][2])
                || $this->is_lushen($y_gan, $this->data['bazi'][4])
                || $this->is_lushen($y_gan, $this->data['bazi'][6])
                || $this->is_lushen($y_gan, $this->data['bazi'][8])
                || $this->is_lushen($y_gan, $d_zhi)
            )
        )
        {
            $taohua += 8;
        }

        if ($this->is_lushen($y_gan, $this->data['bazi'][6]))
        {
            $taohua += 9;
        }

        if (
            in_array($this->data['bazi'][6], ['辰', '戌', '丑', '未'])
            && in_array($y_gan, [$this->param['canggan'][$this->data['bazi'][6]][1], $this->param['canggan'][$this->data['bazi'][6]][2]])
        )
        {
            $taohua += 7;

            if ($this->data['bazi'][5] == '壬' || $this->data['bazi'][5] == '癸')
            {
                $taohua += 3;
            }
        }

        if (in_array($y_zhi, $temp_arr) &&
            (($this->option['recode']['type'] == 1 && in_array($this->param['shishen'][$liuzhi][$this->data['bazi'][5]], ['偏财', '正财']))
                || ($this->option['recode']['type'] == 2 && in_array($this->param['shishen'][$liuzhi][$this->data['bazi'][5]], ['七杀', '正官'])))

        )
        {
            $taohua += 6;
        }

        if ($this->data['bazi'][6] == $y_zhi)
        {
            $taohua += 6;
        }

        if ($this->is_gong($this->data['bazi'][6], $y_zhi))
        {
            $taohua += 6;
        }

        if ($this->is_liuhe($y_zhi, $d_zhi) || $this->is_liuchong($y_zhi, $d_zhi))
        {
            if ($this->param['shishen'][$d_gan][$this->data['bazi'][5]] == '比肩')
            {
                $taohua += 3;
                if ($this->is_liuhe($this->data['bazi'][6], $d_zhi) || $this->is_gong($this->data['bazi'][6], $d_zhi))
                {
                    $taohua += 6;
                }
                if (
                    (
                        ($this->is_liuhe($this->data['bazi'][1], $d_zhi)
                            || $this->is_gong($this->data['bazi'][1], $d_zhi))
                        && in_array($this->param['shishen'][$this->data['bazi'][1]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][3], $d_zhi)
                            || $this->is_gong($this->data['bazi'][3], $d_zhi))
                        && in_array($this->param['shishen'][$this->data['bazi'][3]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][7], $d_zhi)
                            || $this->is_gong($this->data['bazi'][7], $d_zhi))
                        && in_array($this->param['shishen'][$this->data['bazi'][7]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][2], $d_zhi)
                            || $this->is_gong($this->data['bazi'][2], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][2]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][4], $d_zhi)
                            || $this->is_gong($this->data['bazi'][4], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][4]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][6], $d_zhi)
                            || $this->is_gong($this->data['bazi'][6], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][6]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                    ||
                    (
                        ($this->is_liuhe($this->data['bazi'][8], $d_zhi)
                            || $this->is_gong($this->data['bazi'][8], $d_zhi))
                        && in_array($this->param['shishen'][$this->param['canggan'][$this->data['bazi'][8]][0]][$this->data['bazi'][5]], ['偏财', '正财'])
                    )
                )
                {
                    $taohua += 6;
                }
            }
        }

        $advance = [
            'year' => $this->option['advance']['year'],
            'month' => 4,
            'day' => 1,
            'hour' => 12,
            'minute' => 0,
            'timezone' => $this->option['advance']['timezone'] ?? 8,
            'is_summer' => $this->option['advance']['is_summer'] ?? 0,
        ];

        $Astrolog = Astrolog::getInstance();
        $Astrolog->setRecode1($this->option['recode'])
            ->setAdvance($advance)
            ->setExecPrefix(config('astrolog.prefix'))
            ->setIsAstrolabe(false)
            ->setUserSetting(config('astroset.setting1'))
            ->setGetDatas(['thirdprogressed'])
            ->getAstroDatas();

        $th_4_1 = $Astrolog->getDatas('thirdprogressed')['planets'];

        $advance['month'] = 10;
        $th_10_1 = $Astrolog->getDatas('thirdprogressed')['planets'];

        $score_4_1 = 0;
        $score_10_1 = 0;
        if (isset($th_4_1[0]['phase']['0-3']) && $th_4_1[0]['phase']['0-3']['phase_e'] == 0)
        {
            $score_4_1 += 5;
            if (isset($th_4_1[3]['phase']['3-5'])) $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if (isset($th_4_1[3]['phase']['3-4']) && $th_4_1[3]['phase']['3-4']['phase_e'] == 0)
        {
            $score_4_1 += 5;
            if (isset($th_4_1[3]['phase']['3-5'])) $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if (isset($th_4_1[0]['phase']['0-4']) && $th_4_1[0]['phase']['0-4']['phase_e'] == 0)
        {
            $score_4_1 += 2;
            if (isset($th_4_1[4]['phase']['4-5'])) $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7]) || in_array($th_4_1[4]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if ($score_4_1 == 0 && isset($th_4_1[3]['phase']['3-5']))
        {
            $score_4_1 += 5;
            if (in_array($th_4_1[3]['in_house_id'], [5, 7]) || in_array($th_4_1[5]['in_house_id'], [5, 7])) $score_4_1 += 5;
        }
        if (isset($th_10_1[0]['phase']['0-3']) && $th_10_1[0]['phase']['0-3']['phase_e'] == 0)
        {
            $score_10_1 += 5;
            if (isset($th_10_1[3]['phase']['3-5'])) $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if (isset($th_10_1[3]['phase']['3-4']) && $th_10_1[3]['phase']['3-4']['phase_e'] == 0)
        {
            $score_10_1 += 5;
            if (isset($th_10_1[3]['phase']['3-5'])) $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if (isset($th_10_1[0]['phase']['0-4']) && $th_10_1[0]['phase']['0-4']['phase_e'] == 0)
        {
            $score_10_1 += 2;
            if (isset($th_10_1[4]['phase']['4-5'])) $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7]) || in_array($th_10_1[4]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if ($score_10_1 == 0 && isset($th_10_1[3]['phase']['3-5']))
        {
            $score_10_1 += 5;
            if (in_array($th_10_1[3]['in_house_id'], [5, 7]) || in_array($th_10_1[5]['in_house_id'], [5, 7])) $score_10_1 += 5;
        }
        if ($score_4_1 > $score_10_1)
        {
            $taohua += $score_4_1;
        } else
        {
            $taohua += $score_10_1;
        }
        return $taohua;
    }

    /**
     * 获取当前的所有大运流年等信息
     */
    private function getAllData()
    {
        // 获取大运的起运时间
        $this->dayun();
        // 获取八字五行比例
        $this->getWuxingPercent();
        // 日干禄神
//        $this->data['lushen'] = $this->lushen();
        // 运势年份
        $year = $this->option['advance']['year'];
        // 大运的起运年
        $st_year = date('Y', $this->data['st_time']);
        // 获取当前所在大运
        if ($year > $st_year)
        {
            // 大运 干支
            $d_gan_zhi = $this->data['dayun'][floor(($year - $st_year) / 10)];

            // 大运天干
            $d_gan = mb_substr($d_gan_zhi, 0, 1, 'utf-8');
            // 大运地支
            $d_zhi = mb_substr($d_gan_zhi, 1, 1, 'utf-8');

            $this->data['dayun_now'] = [$d_gan, $d_zhi];
        }

        $liunian_year_stem_branche = $this->getYearStemBranche($year);

        if ($this->option['liunian_realtime'] === true)
        {
            // 获取太阳度数
            $sunDeg = (Astrolog::getInstance())->setExecPrefix(config('astrolog.prefix'))->getPlanetOriginData('0', $this->option['advance'])[0] * 1;

            if ($this->option['advance']['month'] < 3 && $sunDeg < 315)
            {
                // 尚未立春
                $this->data['liunian_lichun'] = false;
                // 未立春显示上一年干支
                $liunian_year_stem_branche--;

                if ($liunian_year_stem_branche < 0) $liunian_year_stem_branche = 59;
            } else
            {
                $this->data['liunian_lichun'] = true;
            }
        }
        // 流年 干支
        $y_gan_zhi = $this->param['chinese_era'][$liunian_year_stem_branche];
        // 流年天干
        $y_gan = mb_substr($y_gan_zhi, 0, 1, 'utf-8');
        // 流年地支
        $y_zhi = mb_substr($y_gan_zhi, 1, 1, 'utf-8');
        $this->data['liunian_now'] = [$y_gan, $y_zhi];
        return;
    }

    /**
     * 获取当前的所有大运流年等信息
     */
    private function getAllData2()
    {
        // 获取大运的起运时间
        $this->dayun2();
        // 获取八字五行比例
        $this->getWuxingPercent();
        // 日干禄神
//        $this->data['lushen'] = $this->lushen();
        // 运势年份
        $year = $this->option['advance']['year'];
        // 大运的起运年
        $st_year = date('Y', $this->data['st_time']);
        // 获取当前所在大运
        if ($year > $st_year)
        {
            $index = floor(($year - $st_year) / 10);
            $end = count($this->data['dayun']) - 1;
            // 若页面展示的大运已经全部结束，则展示最后一个大运
            if ($index > $end)
            {
                $index = $end;
            }
            // 大运 干支
            $d_gan_zhi = $this->data['dayun'][$index];

            // 大运天干
            $d_gan = mb_substr($d_gan_zhi, 0, 1, 'utf-8');
            // 大运地支
            $d_zhi = mb_substr($d_gan_zhi, 1, 1, 'utf-8');

            $this->data['dayun_now'] = [$d_gan, $d_zhi];
        }

        $liunian_year_stem_branche = $this->getYearStemBranche($year);

        if ($this->option['liunian_realtime'] === true)
        {
            // 获取太阳度数
            $sunDeg = (Astrolog::getInstance())->setExecPrefix(config('astrolog.prefix'))->getPlanetOriginData('0', $this->option['advance'])[0] * 1;

            if ($this->option['advance']['month'] < 3 && $sunDeg < 315)
            {
                // 尚未立春
                $this->data['liunian_lichun'] = false;
                // 未立春显示上一年干支
                $liunian_year_stem_branche--;

                if ($liunian_year_stem_branche < 0) $liunian_year_stem_branche = 59;
            } else
            {
                $this->data['liunian_lichun'] = true;
            }
        }
        // TODO 若当前流年不在展示范围内，则仅展示边界流年。
        // 流年 干支
        $y_gan_zhi = $this->param['chinese_era'][$liunian_year_stem_branche];
        // 流年天干
        $y_gan = mb_substr($y_gan_zhi, 0, 1, 'utf-8');
        // 流年地支
        $y_zhi = mb_substr($y_gan_zhi, 1, 1, 'utf-8');
        $this->data['liunian_now'] = [$y_gan, $y_zhi];
        return;
    }

    private function getyearConclusionData()
    {
        $this->data['shenwang'] = $this->is_shenwang();
        $this->data['liunianzhushen'] = $this->getZhuShen();
        $this->data['ganzhibuxie'] = $this->is_ganzhibuxie();
        $this->data['anjing'] = $this->is_anjing();
        $this->data['donggong'] = $this->donggong();
        $this->data['dongshen'] = $this->dongshen();
        $this->shanggong_shangshen();
        return;
    }

    /**
     * 动宫
     * 流年与八字原局某柱形成干合、支合、支冲、支穿、支拱，支刑、出干、入支、现干、现支则计算动宫指数
     * 干合1
     * 支合1
     * 支冲1
     * 支穿0.5
     * 支拱0.4
     * 支刑
     *    如命运年凑齐三刑1
     *    如未凑齐则0.5
     * 出干0.5 是指流干之禄是命局某柱地支
     * 入支0.5 是指流支是命局某柱天干之禄
     * 现干0.8 流干为某柱天干
     * 现支0.8 流支为某柱地支
     */
    public function donggong()
    {
        $liu = $this->data['liunian_now'];

        $ming_zhu = [
            [$this->data['bazi'][1], $this->data['bazi'][2],],
            [$this->data['bazi'][3], $this->data['bazi'][4],],
            [$this->data['bazi'][5], $this->data['bazi'][6],],
            [$this->data['bazi'][7], $this->data['bazi'][8],],
        ];
        $score = [0, 0, 0, 0];
        foreach ($ming_zhu as $k => $mzhu)
        {
            if ($this->is_wuhe($liu[0], $mzhu[0]))
            {
                $score[$k] += 1;
            }
            if ($this->is_liuhe($liu[1], $mzhu[1]))
            {
                $score[$k] += 1;
            }
            if ($this->is_liuchong($liu[1], $mzhu[1]))
            {
                $score[$k] += 1;
            }
            if ($this->is_liuhai($liu[1], $mzhu[1]))
            {
                $score[$k] += 0.5;
            }
            if ($this->is_gong($liu[1], $mzhu[1]))
            {
                $score[$k] += 0.4;
            }
            if ($this->is_xing($liu[1], $mzhu[1]))
            {
                if ($this->data['dayun_now'] != null
                    && $this->is_sanxing($liu[1], $mzhu[1], $this->data['dayun_now'][1]))
                {
                    $score[$k] += 1;
                } else
                {
                    $score[$k] += 0.5;
                }
            }
            if ($this->is_lushen($liu[0], $mzhu[1]))
            {
                $score[$k] += 0.5;
            }
            if ($this->is_lushen($liu[1], $mzhu[0]))
            {
                $score[$k] += 0.5;
            }
            if ($liu[0] == $mzhu[0])
            {
                $score[$k] += 0.8;
            }
            if ($liu[1] == $mzhu[0])
            {
                $score[$k] += 0.8;
            }
        }
        return $score;
    }

    /**
     * 动神
     * 比肩、劫财、食神、伤官、偏财、正财、七杀、正官、偏印、正印
     * 流干出现+0.6
     * 流支本气出现+0.5
     * 命运某干被流干合，相合双方均+0.5
     * 命运某支被流支冲合，相冲相合双方本气+0.5
     * 命运某支被流支拱，被拱者本气+0.3
     * 命运某支被流支刑穿，相刑穿双方本气+0.3
     *      如凑齐三刑改为0.5
     */
    public function dongshen()
    {
        $liu = $this->data['liunian_now'];

        $liuzhi_benqi = $this->param['canggan'][$liu[1]][0];

        $rigan = $this->data['bazi'][5];

        $zhus = [
            [$this->data['bazi'][1], $this->data['bazi'][2],],
            [$this->data['bazi'][3], $this->data['bazi'][4],],
            [$this->data['bazi'][5], $this->data['bazi'][6],],
            [$this->data['bazi'][7], $this->data['bazi'][8],],
        ];

        $score = [
            '比肩' => 0, '劫财' => 0,
            '食神' => 0, '伤官' => 0,
            '偏财' => 0, '正财' => 0,
            '七杀' => 0, '正官' => 0,
            '偏印' => 0, '正印' => 0,
        ];
        // 流干出现+0.6
        $score[$this->param['shishen'][$liu[0]][$rigan]] += 0.6;
        // 流支本气出现+0.5
        $score[$this->param['shishen'][$liuzhi_benqi][$rigan]] += 0.5;

        if ($this->data['dayun_now'] != null)
        {
            $zhus[] = $this->data['dayun_now'];
        }

        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];
        $liuzhi_shishen = $this->param['shishen'][$liuzhi_benqi][$rigan];

        foreach ($zhus as $k => $zhu)
        {
            $zhugan_shishen = $this->param['shishen'][$zhu[0]][$rigan];
            $zhuzhi_shishen = $this->param['shishen'][$this->param['canggan'][$zhu[1]][0]][$rigan];

            if ($this->is_wuhe($zhu[0], $liu[0]))
            {
                // 命运某干被流干合，相合双方均+0.5
                $score[$liugan_shishen] += 0.5;
                // 命运某干被流干合，相合双方均+0.5  日干不加分
                if ($k != 2) $score[$zhugan_shishen] += 0.5;
            }
            // 命运某支被流支冲合，相冲相合双方本气+0.5
            if ($this->is_liuchong($liu[1], $zhu[1]) || $this->is_liuhe($liu[1], $zhu[1]))
            {
                $score[$liuzhi_shishen] += 0.5;
                $score[$zhuzhi_shishen] += 0.5;
            }
            // 命运某支被流支拱，被拱者本气+0.3
            if ($this->is_gong($liu[1], $zhu[1]) || $this->is_liuhe($liu[1], $zhu[1]))
            {
                $score[$zhuzhi_shishen] += 0.3;
            }
            // 命运某支被流支刑穿，相刑穿双方本气+0.3  如凑齐三刑改为0.5
            if ($this->is_xing($liu[1], $zhu[1]) || $this->is_liuhai($liu[1], $zhu[1]))
            {
                if (($this->data['dayun_now'] != null
                        && $this->is_sanxing($liu[1], $zhu[1], $this->data['dayun_now'][1]))
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][2])
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][4])
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][6])
                    || $this->is_sanxing($liu[1], $zhu[1], $this->data['bazi'][8])
                )
                {
                    $score[$liuzhi_shishen] += 0.5;
                    $score[$zhuzhi_shishen] += 0.5;
                } else
                {
                    $score[$liuzhi_shishen] += 0.3;
                    $score[$zhuzhi_shishen] += 0.3;
                }
            }
        }
        return $score;
    }

    /**
     * 伤宫/伤神
     * 计算原局受伤度
     *   天干
     *      坐下地支是该干死绝病地或被坐下地支截脚0.5
     *          截脚是地支本气与天干本气同性且克之 天干是坐支本气的偏财
     *      被邻干合克或正克1
     *      被非邻干合克或正克0.5
     *      被月柱本气克0.5
     *      被运干正克0.5
     *      被运干生0.3
     *      被邻干生-0.4
     *      月柱或坐下有该干的根-0.4（如果是禄-1）
     *      该干在地支有根且受地支本气生两次或以上-0.5
     *   地支
     *      被盖头0.5
     *          盖头是同柱天干与该地支本气相同并克之
     *      被邻支或运支刑冲穿1
     *          且克+0.5
     *      被非邻支刑冲穿0.8
     *          且克+0.4
     *   宫位受伤度为该柱天干地支受伤之合
     *   十神受伤度是天干地支本气十神的受伤度
     *      如命局有多个该十神，取受伤最高者
     * 计算流年受伤度
     *   流支与命运某柱刑+0.3（凑齐三刑改为0.5）冲+0.5穿+0.5（原局受作用的地支本气与宫位受伤度均+相应值）
     *      存在干支不协或双冲+1
     * 流干如为原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度
     * 流干如正克或合克原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度+0.3
     * 相穿呼应
     *   如本命出现两地支相穿，大运地支与流年地支分别是相穿的两地支，本命相穿两宫两支本气各+1破坏度
     *   如本命出现两地支相穿，流支为相穿地支之一，流干的禄为相穿地支的另一个，本命相穿两宫两支本气各+1破坏度
     *   如本命与大运地支相穿，流支为相穿地支之一，两穿地支及本命被穿宫位各+1破坏度
     * 计算年月日时各宫在流年的受伤指数
     * 计算各十神在流年的受伤指数
     */
    public function shanggong_shangshen()
    {
        $liu = $this->data['liunian_now'];
        $rigan = $this->data['bazi'][5];
        $changsheng = $this->param['changsheng'];
        $liugan_shishen = $this->param['shishen'][$liu[0]][$rigan];

        $ming_zhu = [
            [$this->data['bazi'][1], $this->data['bazi'][2],],
            [$this->data['bazi'][3], $this->data['bazi'][4],],
            [$this->data['bazi'][5], $this->data['bazi'][6],],
            [$this->data['bazi'][7], $this->data['bazi'][8],],
        ];
        $gong_score = [0, 0, 0, 0];
        $shen_score = [
            '比肩' => 0, '劫财' => 0,
            '食神' => 0, '伤官' => 0,
            '偏财' => 0, '正财' => 0,
            '七杀' => 0, '正官' => 0,
            '偏印' => 0, '正印' => 0,
        ];

        // 计算原局受伤度
        foreach ($ming_zhu as $k => $mzhu)
        {
            $shen_score_temp = [
                '比肩' => 0, '劫财' => 0,
                '食神' => 0, '伤官' => 0,
                '偏财' => 0, '正财' => 0,
                '七杀' => 0, '正官' => 0,
                '偏印' => 0, '正印' => 0,
            ];

            $zhi_benqi = $this->param['canggan'][$mzhu[1]][0];

            $zhugan_shishen = $this->param['shishen'][$mzhu[0]][$rigan];
            // 坐下地支是该干死绝病地或被坐下地支截脚0.5
            // 截脚：天干是坐支本气的偏财
            if (in_array($changsheng[$mzhu[0]][$mzhu[1]], ['死', '绝', '病 '])
                || $this->is_jiejiao($mzhu[0], $mzhu[1]))
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            /**
             * 被邻干合克或正克1
             * A干被合克，是A干被对方合，同时对方是A干的正官
             * 合克，就是天干五合带克，比如庚来合乙，庚合克乙
             * 正克是辛来克乙
             */
            $linggan = [];
            $lingzhi = [];
            $is_linggan_heke = false;
            if (isset($ming_zhu[$k - 1]))
            {
                $linggan[] = $ming_zhu[$k - 1][0];
                $lingzhi[] = $ming_zhu[$k - 1][1];
            }
            if (isset($ming_zhu[$k + 1]))
            {
                $linggan[] = $ming_zhu[$k + 1][0];
                $lingzhi[] = $ming_zhu[$k + 1][1];
            }
            foreach ($linggan as $lg)
            {
                if (($this->is_wuhe($lg, $mzhu[0]) && $this->param['shishen'][$lg][$mzhu[0]] == '正官')
                    || $this->param['shishen'][$lg][$mzhu[0]] == '七杀')
                {
                    $is_linggan_heke = true;
                }
            }
            if ($is_linggan_heke)
            {
                $gong_score[$k] += 1;
                $shen_score_temp[$zhugan_shishen] += 1;
            }
            /**
             * 被非邻干合克或正克0.5
             */
            $is_fei_linggan_heke = false;
            $feilinggan = [];
            $feilingzhi = [];
            if (isset($ming_zhu[$k - 2]))
            {
                $feilinggan[] = $ming_zhu[$k - 2][0];
                $feilingzhi[] = $ming_zhu[$k - 2][1];
            }
            if (isset($ming_zhu[$k - 3]))
            {
                $feilinggan[] = $ming_zhu[$k - 3][0];
                $feilingzhi[] = $ming_zhu[$k - 3][1];
            }
            if (isset($ming_zhu[$k + 2]))
            {
                $feilinggan[] = $ming_zhu[$k + 2][0];
                $feilingzhi[] = $ming_zhu[$k + 2][1];
            }
            if (isset($ming_zhu[$k + 3]))
            {
                $feilinggan[] = $ming_zhu[$k + 3][0];
                $feilingzhi[] = $ming_zhu[$k + 3][1];
            }

            foreach ($feilinggan as $flg)
            {
                if (($this->is_wuhe($flg, $mzhu[0]) && $this->param['shishen'][$flg][$mzhu[0]] == '正官')
                    || $this->param['shishen'][$flg][$mzhu[0]] == '七杀')
                {
                    $is_fei_linggan_heke = true;
                }
            }
            if ($is_fei_linggan_heke)
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            // 被月柱本气克0.5
            $yuezhu_benqi = $this->param['canggan'][$this->data['bazi'][4]][0];
            if (in_array($this->param['shishen'][$yuezhu_benqi][$mzhu[0]], ['七杀', '正官']))
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            // 被运干正克0.5
            if ($this->data['dayun_now'] != null
                && $this->param['shishen'][$this->data['dayun_now'][0]][$mzhu[0]] == '七杀')
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$zhugan_shishen] += 0.5;
            }
            // 被运干生0.3
            if ($this->data['dayun_now'] != null
                && in_array($this->param['shishen'][$this->data['dayun_now'][0]][$mzhu[0]], ['正印', '偏印']))
            {
                $gong_score[$k] += 0.3;
                $shen_score_temp[$zhugan_shishen] += 0.3;
            }
            // 被邻干生-0.4
            $is_linggan_sheng = false;
            foreach ($linggan as $lg)
            {
                if (in_array($this->param['shishen'][$lg][$mzhu[0]], ['正印', '偏印']))
                {
                    $is_linggan_sheng = true;
                }
            }
            if ($is_linggan_sheng)
            {
                $gong_score[$k] += -0.4;
                $shen_score_temp[$zhugan_shishen] += -0.4;
            }
            /**
             * 月柱或坐下有该干的根-0.4（如果是禄-1）
             * (如果某地支含有与某天干相同的五行，就是该天干的根)
             */
            $is_yuezhu_zuoxia_yougen = false;
            $is_lushen = false;
            $is_yougen = false;
            $mzhu_sheng_num = 0;

            foreach ($ming_zhu as $k2 => $mzhu2)
            {
                $canggan = $this->param['canggan'][$mzhu2[1]];

                foreach ($canggan as $cg)
                {
                    if ($is_yuezhu_zuoxia_yougen === false
                        && $this->param['wuxing'][$cg] == $this->param['wuxing'][$mzhu[0]])
                    {
                        $is_yougen = true;
                        // 月柱 或 坐下
                        if ($k2 == 1 || $k == $k2)
                        {
                            $is_yuezhu_zuoxia_yougen = true;
                            if ($this->is_lushen($mzhu[0], $mzhu2[1]))
                            {
                                $is_lushen = true;
                            }
                        }
                    }
                }
                if (in_array($this->param['shishen'][$canggan[0]][$mzhu[0]], ['正印', '偏印']))
                {
                    $mzhu_sheng_num++;
                }
            }
            if ($is_yuezhu_zuoxia_yougen)
            {
                if ($is_lushen)
                {
                    $gong_score[$k] += -1;
                    $shen_score_temp[$zhugan_shishen] += -1;
                } else
                {
                    $gong_score[$k] += -0.4;
                    $shen_score_temp[$zhugan_shishen] += -0.4;
                }
            }
            // 该干在地支有根且受地支本气生两次或以上-0.5
            if ($is_yougen && $mzhu_sheng_num >= 2)
            {
                $gong_score[$k] += -0.5;
                $shen_score_temp[$zhugan_shishen] += -0.5;
            }
            // 当前地支本气的十神
            $dizhi_benqi_shishen = $this->param['shishen'][$zhi_benqi][$rigan];
            // 地支
            //	被盖头0.5 盖头是同柱天干与该地支本气相同并克之
            //	被邻支或运支刑冲穿1
            //		且克+0.5
            //	被非邻支刑冲穿0.8
            //		且克+0.4
            if ($this->is_gaitou($mzhu[0], $mzhu[1]))
            {
                $gong_score[$k] += 0.5;
                $shen_score_temp[$dizhi_benqi_shishen] += 0.5;
            }
            $is_lingzhi_xcc = false;
            $is_lingzhi_xcc_and_ke = false;
            if ($this->data['dayun_now'] != null && ($this->is_xing($mzhu[1], $this->data['dayun_now'][1])
                    || $this->is_liuchong($mzhu[1], $this->data['dayun_now'][1])
                    || $this->is_liuhai($mzhu[1], $this->data['dayun_now'][1])))
            {
                $is_lingzhi_xcc = true;
                if (in_array($this->param['shishen'][$mzhu[0]][$this->param['canggan'][$this->data['dayun_now'][1]][0]],
                    ['正官', '七杀', '偏财', '正财']))
                {
                    $is_lingzhi_xcc_and_ke = true;
                }
            }
            if ($is_lingzhi_xcc === false)
            {
                foreach ($lingzhi as $lz)
                {
                    if ($is_lingzhi_xcc === false && ($this->is_xing($mzhu[1], $lz)
                            || $this->is_liuchong($mzhu[1], $lz)
                            || $this->is_liuhai($mzhu[1], $lz))
                    )
                    {
                        $is_lingzhi_xcc = true;
                        if (in_array($this->param['shishen'][$mzhu[0]][$this->param['canggan'][$lz][0]],
                            ['正官', '七杀', '偏财', '正财']))
                        {
                            $is_lingzhi_xcc_and_ke = true;
                        }
                    }
                }
            }
            // 被邻支或运支刑冲穿1
            if ($is_lingzhi_xcc)
            {
                $gong_score[$k] += 1;
                $shen_score_temp[$dizhi_benqi_shishen] += 1;
                // 且克+0.5
                if ($is_lingzhi_xcc_and_ke)
                {
                    $gong_score[$k] += 0.5;
                    $shen_score_temp[$dizhi_benqi_shishen] += 0.5;
                }
            }
            $is_feilingzhi_xcc = false;
            $is_feilingzhi_xcc_and_ke = false;
            foreach ($feilingzhi as $flz)
            {
                if ($is_feilingzhi_xcc === false && ($this->is_xing($mzhu[1], $flz)
                        || $this->is_liuchong($mzhu[1], $flz)
                        || $this->is_liuhai($mzhu[1], $flz))
                )
                {
                    $is_feilingzhi_xcc = true;
                    if (in_array($this->param['shishen'][$mzhu[0]][$this->param['canggan'][$flz][0]],
                        ['正官', '七杀', '偏财', '正财']))
                    {
                        $is_feilingzhi_xcc_and_ke = true;
                    }
                }
            }
            // 被非邻支刑冲穿0.8
            if ($is_feilingzhi_xcc)
            {
                $gong_score[$k] += 0.8;
                $shen_score_temp[$dizhi_benqi_shishen] += 0.8;
                // 且克 且克+0.4
                if ($is_feilingzhi_xcc_and_ke)
                {
                    $gong_score[$k] += 0.4;
                    $shen_score_temp[$dizhi_benqi_shishen] += 0.4;
                }
            }
            // 十神受伤度是天干地支本气十神的受伤度 如命局有多个该十神，取受伤最高者
            if ($shen_score[$zhugan_shishen] < $shen_score_temp[$zhugan_shishen])
            {
                $shen_score[$zhugan_shishen] = $shen_score_temp[$zhugan_shishen];
            }
            if ($shen_score[$dizhi_benqi_shishen] < $shen_score_temp[$dizhi_benqi_shishen])
            {
                $shen_score[$dizhi_benqi_shishen] = $shen_score_temp[$dizhi_benqi_shishen];
            }
        }

        // 计算流年受伤度
        $liu_gong_score = [0, 0, 0, 0];
        $liu_shen_score = [
            '比肩' => 0, '劫财' => 0,
            '食神' => 0, '伤官' => 0,
            '偏财' => 0, '正财' => 0,
            '七杀' => 0, '正官' => 0,
            '偏印' => 0, '正印' => 0,
        ];
        /**
         * 流支与命运某柱刑+0.3（凑齐三刑改为0.5）冲+0.5穿+0.5（原局受作用的地支本气与宫位受伤度均+相应值）
         *  存在干支不协或双冲或正冲+1
         * 正冲是 相冲的两柱天干相同，比如流年甲寅，本命甲申
         */
        foreach ($ming_zhu as $k1 => $mzhu)
        {
            $zhi_benqi = $this->param['canggan'][$mzhu[1]][0];

            // 当前地支本气的十神
            $dizhi_benqi_shishen = $this->param['shishen'][$zhi_benqi][$rigan];

            $zhugan_shishen = $this->param['shishen'][$mzhu[0]][$rigan];

            if ($this->is_xing($liu[1], $mzhu[1]))
            {
                if ($this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[0][1])
                    || $this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[1][1])
                    || $this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[2][1])
                    || $this->is_sanxing($liu[1], $mzhu[1], $ming_zhu[3][1]))
                {
                    $liu_gong_score[$k1] += 0.5;
                    $liu_shen_score[$dizhi_benqi_shishen] += 0.5;

                    if ($this->data['ganzhibuxie'] === true
                        || $this->data['shuangchong'] === true
                        || $liu[0] == $mzhu[0]
                    )
                    {
                        $liu_gong_score[$k1] += 1;
                        $liu_shen_score[$dizhi_benqi_shishen] += 1;
                    }
                } else
                {
                    $liu_gong_score[$k1] += 0.3;
                    $liu_shen_score[$dizhi_benqi_shishen] += 0.3;

                    if ($this->data['ganzhibuxie'] === true
                        || $this->data['shuangchong'] === true
                        || $liu[0] == $mzhu[0]
                    )
                    {
                        $liu_gong_score[$k1] += 1;
                        $liu_shen_score[$dizhi_benqi_shishen] += 1;
                    }
                }
            } elseif ($this->is_liuchong($liu[1], $mzhu[1]))
            {
                $liu_gong_score[$k1] += 0.5;
                $liu_shen_score[$dizhi_benqi_shishen] += 0.5;
                if ($this->data['ganzhibuxie'] === true
                    || $this->data['shuangchong'] === true
                    || $liu[0] == $mzhu[0]
                )
                {
                    $liu_gong_score[$k1] += 1;
                    $liu_shen_score[$dizhi_benqi_shishen] += 1;
                }
            } elseif ($this->is_liuhai($liu[1], $mzhu[1]))
            {
                $liu_gong_score[$k1] += 0.5;
                $liu_shen_score[$dizhi_benqi_shishen] += 0.5;

                if ($this->data['ganzhibuxie'] === true
                    || $this->data['shuangchong'] === true
                    || $liu[0] == $mzhu[0])
                {
                    $liu_gong_score[$k1] += 1;
                    $liu_shen_score[$dizhi_benqi_shishen] += 1;
                }
            }
            // 流干如为原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度
            if ($liu[0] == $mzhu[0])
            {
                $liu_gong_score[$k1] += $gong_score[$k1];
                $liu_shen_score[$zhugan_shishen] += $shen_score[$zhugan_shishen];
            }
            // 流干如正克或合克原局某宫干，该宫与该十神在流年的受伤度=原局受伤度+流年受伤度+0.3
            if (($this->is_wuhe($liu[0], $mzhu[0]) && $this->param['shishen'][$liu[0]][$mzhu[0]] == '正官')
                || $this->param['shishen'][$liu[0]][$mzhu[0]] == '七杀')
            {
                $liu_gong_score[$k1] += $gong_score[$k1] + 0.3;
                $liu_shen_score[$zhugan_shishen] += $shen_score[$zhugan_shishen] + 0.3;
            }

            /**
             * 流干如被原局某宫干正克
             *  流干支与该宫成双冲 该干十神流年受伤+1
             *  流支与命运某支刑冲穿 该干十神流年受伤+0.5
             */
            if ($this->param['shishen'][$mzhu[0]][$liu[0]] == '七杀')
            {
                if ($this->is_shuangchong($liu, [$mzhu]))
                {
                    $liu_shen_score[$liugan_shishen] += 0.5;
                }
            }
        }
        if (
            ($this->param['shishen'][$this->data['bazi'][1]][$liu[0]] == '七杀'
                || $this->param['shishen'][$this->data['bazi'][3]][$liu[0]] == '七杀'
                || $this->param['shishen'][$this->data['bazi'][5]][$liu[0]] == '七杀'
                || $this->param['shishen'][$this->data['bazi'][7]][$liu[0]] == '七杀'
            )
            &&
            (
                $this->is_xing($liu[1], $this->data['bazi'][2])
                || $this->is_liuchong($liu[1], $this->data['bazi'][2])
                || $this->is_liuhai($liu[1], $this->data['bazi'][2])
                || $this->is_xing($liu[1], $this->data['bazi'][4])
                || $this->is_liuchong($liu[1], $this->data['bazi'][4])
                || $this->is_liuhai($liu[1], $this->data['bazi'][4])
                || $this->is_xing($liu[1], $this->data['bazi'][6])
                || $this->is_liuchong($liu[1], $this->data['bazi'][6])
                || $this->is_liuhai($liu[1], $this->data['bazi'][6])
                || $this->is_xing($liu[1], $this->data['bazi'][8])
                || $this->is_liuchong($liu[1], $this->data['bazi'][8])
                || $this->is_liuhai($liu[1], $this->data['bazi'][8])
                || (
                    $this->data['dayun_now'] != null
                    &&
                    (
                        $this->is_xing($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuchong($liu[1], $this->data['dayun_now'][1])
                        || $this->is_liuhai($liu[1], $this->data['dayun_now'][1])
                    )
                )
            )
        )
        {
            $liu_shen_score[$liugan_shishen] += 0.5;
        }
        // 相穿呼应
        foreach ($ming_zhu as $k2 => $mzhu1)
        {
            $dizhi_benqi_shishen1 = $this->param['shishen'][$this->param['canggan'][$mzhu1[1]][0]][$rigan];
            foreach ($ming_zhu as $k3 => $mzhu2)
            {
                $dizhi_benqi_shishen2 = $this->param['shishen'][$this->param['canggan'][$mzhu2[1]][0]][$rigan];
                //	如本命出现两地支相穿，大运地支与流年地支分别是相穿的两地支
                //	如本命出现两地支相穿，流支为相穿地支之一
                if ($k3 > $k2 && $this->is_liuhai($mzhu1[1], $mzhu2[1]))
                {
                    if ($liu[1] == $mzhu1[1])
                    {
                        // 大运地支与流年地支分别是相穿的两地支，本命相穿两宫两支本气各+1破坏度
                        if ($this->data['dayun_now'] != null && $this->data['dayun_now'][1] == $mzhu2[1])
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                        // 流干的禄为相穿地支的另一个，本命相穿两宫两支本气各+1破坏度
                        if ($this->is_lushen($liu[0], $mzhu2[1]))
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                    } elseif ($liu[1] == $mzhu2[1])
                    {
                        // 大运地支与流年地支分别是相穿的两地支，本命相穿两宫两支本气各+1破坏度
                        if ($this->data['dayun_now'] != null && $this->data['dayun_now'][1] == $mzhu1[1])
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                        // 流干的禄为相穿地支的另一个，本命相穿两宫两支本气各+1破坏度
                        if ($this->is_lushen($liu[0], $mzhu1[1]))
                        {
                            $liu_gong_score[$k2] += 1;
                            $liu_gong_score[$k3] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                            $liu_shen_score[$dizhi_benqi_shishen2] += 1;
                        }
                    }
                }
            }
            //	如本命与大运地支相穿，流支为相穿地支之一，两穿地支及本命被穿宫位各+1破坏度
            if ($this->data['dayun_now'] != null &&
                $this->is_liuhai($this->data['dayun_now'][1], $mzhu1[1])
                && ($liu[1] == $this->data['dayun_now'][1] || $liu[1] == $mzhu1[1]))
            {
                $dayun_benqi_shishen = $this->param['shishen'][$this->param['canggan'][$this->data['dayun_now'][1]][0]][$rigan];
                $liu_gong_score[$k2] += 1;
                $liu_shen_score[$dizhi_benqi_shishen1] += 1;
                $liu_shen_score[$dayun_benqi_shishen] += 1;
            }
        }

        $this->data['shanggong'] = $liu_gong_score;
        $this->data['shangshen'] = $liu_shen_score;

        $this->data['or_shanggong'] = $gong_score;
        $this->data['or_shangshen'] = $shen_score;

        return;
    }

    /**
     * 获取天干五行得分
     * @param null $gan
     * @param null $zhi
     */
    private function getTianGanScore($gan = null, $zhi = null)
    {
        $base = 6;
        $config_wuxing = $this->param['wuxing'];
        $config_shishen = $this->param['shishen'];
        $config_canggan = $this->param['canggan'];

        $wuxing = $config_wuxing[$gan];
        $status = false;
        $change = 0;
        foreach ($config_canggan[$zhi] as $k1 => $cg1)
        {
            // 本气40
            if ($k1 === 0)
            {
                // 坐支本气为相同五行成分
                if ($wuxing == $config_wuxing[$cg1])
                {
                    $status = true;
                    $change += 5;
                }
                // 坐支本气正印
                if ($config_shishen[$cg1][$gan] == '正印')
                {
                    $status = true;
                    $change += 3;
                } // 坐支本气偏印
                elseif ($config_shishen[$cg1][$gan] == '偏印')
                {
                    $status = true;
                    $change += 1;
                } // 坐支本气七杀
                elseif ($config_shishen[$cg1][$gan] == '七杀')
                {
                    $status = true;
                    $change += -4;
                } // 坐支本气正官
                elseif ($config_shishen[$cg1][$gan] == '正官')
                {
                    $status = true;
                    $change += -2;
                } // 坐支本气正财
                elseif ($config_shishen[$cg1][$gan] == '正财')
                {
                    $status = true;
                    $change += -1;
                } // 坐支本气偏财
                elseif ($config_shishen[$cg1][$gan] == '偏财')
                {
                    $status = true;
                    $change += -1;
                }
            } else
            {
                // 坐支非本气为相同五行成分
                if ($wuxing == $config_wuxing[$cg1])
                {
                    $status = true;
                    $change += 3;
                }
            }
        }
        if ($status == true) $change += $base;

        $this->data['score'][$wuxing] += $change;
    }

    /**
     * 获取地支五行得分
     * @param null $zhi
     * @param bool $is_m 是否为月令
     */
    private function getDizhiScore($zhi = null, $is_m = false)
    {
        $metal = $wood = $water = $fire = $earth = 0;
        switch ($zhi)
        {
            case '子':
                $water += 10;
                break;
            case '丑':
                $earth += 6;
                $water += 2;
                $metal += 2;
                break;
            case '寅':
                $wood += 7;
                $fire += 2.5;
                $earth += 0.5;
                break;
            case '卯':
                $wood += 10;
                break;
            case '辰':
                $earth += 6;
                $wood += 2;
                $water += 2;
                break;
            case '巳':
                $fire += 7;
                $earth += 2.5;
                $metal += 0.5;
                break;
            case '午':
                $fire += 8;
                $earth += 4;
                break;
            case '未':
                $earth += 6;
                $wood += 2;
                $fire += 2;
                break;
            case '申':
                $metal += 7;
                $water += 2.5;
                $earth += 0.5;
                break;
            case '酉':
                $metal += 10;
                break;
            case '戌':
                $earth += 6;
                $fire += 2;
                $metal += 2;
                break;
            case '亥':
                $water += 7;
                $wood += 3;
                break;
        }

        if ($is_m)
        {
            $metal *= 2;
            $wood *= 2;
            $water *= 2;
            $fire *= 2;
            $earth *= 2;
        }
        $this->data['score']['金'] += $metal;
        $this->data['score']['木'] += $wood;
        $this->data['score']['水'] += $water;
        $this->data['score']['火'] += $fire;
        $this->data['score']['土'] += $earth;
    }

    /**
     * 五行生克得分
     * @param $score
     * @param null $rizhu
     */
    private function getShengkeScore($rizhu = null)
    {
        $config_wuxing = $this->param['wuxing'];

        $wuxing = $config_wuxing[$rizhu];

        switch ($wuxing)
        {
            case '金':
                $this->data['score']['金'] *= 1;// 同我
                $this->data['score']['土'] *= 0.5;// 生我
                $this->data['score']['火'] *= 1;// 克我
                $this->data['score']['木'] *= 0.6;// 我克
                $this->data['score']['水'] *= 0.3;// 我生
                break;
            case '水':
                $this->data['score']['水'] *= 1;
                $this->data['score']['金'] *= 0.5;
                $this->data['score']['土'] *= 1;
                $this->data['score']['火'] *= 0.6;
                $this->data['score']['木'] *= 0.3;
                break;
            case '木':
                $this->data['score']['木'] *= 1;
                $this->data['score']['水'] *= 0.5;
                $this->data['score']['金'] *= 1;
                $this->data['score']['土'] *= 0.6;
                $this->data['score']['火'] *= 0.3;
                break;
            case '火':
                $this->data['score']['火'] *= 1;
                $this->data['score']['木'] *= 0.5;
                $this->data['score']['水'] *= 1;
                $this->data['score']['金'] *= 0.6;
                $this->data['score']['土'] *= 0.3;
                break;
            case '土':
                $this->data['score']['土'] *= 1;
                $this->data['score']['火'] *= 0.5;
                $this->data['score']['木'] *= 1;
                $this->data['score']['水'] *= 0.6;
                $this->data['score']['金'] *= 0.3;
                break;
        }
    }

    /**
     * 获取五行百分比
     * @param array $bazi
     * @return mixed
     */
    public function getWuxingPercent($bazi = [])
    {
        if (empty($bazi))
        {
            $bazi = $this->data['bazi'];
        }
        $this->getTianGanScore($bazi[1], $bazi[2]);
        $this->getTianGanScore($bazi[3], $bazi[4]);
        $this->getTianGanScore($bazi[5], $bazi[6]);
        $this->getTianGanScore($bazi[7], $bazi[8]);
        $this->getDizhiScore($bazi[2]);
        $this->getDizhiScore($bazi[4], true);
        $this->getDizhiScore($bazi[6]);
        $this->getDizhiScore($bazi[8]);
        $this->getShengkeScore($bazi[5]);

        $sum = array_sum($this->data['score']);
        $wuxingPerc = [];
        foreach ($this->data['score'] as $k => $s)
        {
            $aaaa = $s / $sum * 100;
//            echo $k . ' : ' . $aaaa . PHP_EOL;
            $wuxingPerc[$k] = round($s / $sum * 100, 0);
        }
        $this->data['wuxing_perc'] = $wuxingPerc;
        switch ($this->param['wuxing'][$bazi[5]])
        {
            case '金':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $wuxingPerc['金'],
                    '印' => $wuxingPerc['土'],
                    '官杀' => $wuxingPerc['火'],
                    '财' => $wuxingPerc['木'],
                    '食伤' => $wuxingPerc['水'],
                ];
                break;
            case '水':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $wuxingPerc['水'],
                    '印' => $wuxingPerc['金'],
                    '官杀' => $wuxingPerc['土'],
                    '财' => $wuxingPerc['火'],
                    '食伤' => $wuxingPerc['木'],
                ];
                break;
            case '木':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $wuxingPerc['木'],
                    '印' => $wuxingPerc['水'],
                    '官杀' => $wuxingPerc['金'],
                    '财' => $wuxingPerc['土'],
                    '食伤' => $wuxingPerc['火'],
                ];
                break;
            case '火':
                $this->data['shishen_wuxing'] = [
                    '比劫' => $wuxingPerc['火'],
                    '印' => $wuxingPerc['木'],
                    '官杀' => $wuxingPerc['水'],
                    '财' => $wuxingPerc['金'],
                    '食伤' => $wuxingPerc['土'],
                ];
                break;
            default :
                $this->data['shishen_wuxing'] = [
                    '比劫' => $wuxingPerc['土'],
                    '印' => $wuxingPerc['火'],
                    '官杀' => $wuxingPerc['木'],
                    '财' => $wuxingPerc['水'],
                    '食伤' => $wuxingPerc['金'],
                ];
                break;
        }
        return $wuxingPerc;
    }

    /**
     * 获取八字
     * @param $time
     * @param int $sunDeg
     * @param bool $getHour
     * @return array
     */
    public function getBazi($time, $sunDeg = 0, $getHour = false)
    {
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 十二地支
        $Earthly_Branches = $this->param['earthly_branches'];
        // 六十甲子
        $chinese_era = $this->param['chinese_era'];

        // 增加夏令时计算
        if ($this->option['recode']['is_summer'] == 1)
        {
            $time -= 3600;
        }

        // 若为真太阳时则
        if ($this->option['time_type'] == 1)
        {
            $yy = (int)date('Y', $time);
            $mm = (int)date('m', $time);
            $dd = (int)date('d', $time);
            $hh = (int)date('H', $time);
            $ii = (int)date('i', $time);
            $longitude = ($this->option['recode']['long_deg'] + $this->option['recode']['long_min'] / 60) * $this->option['recode']['ew'];
            $latitude = ($this->option['recode']['lat_deg'] + $this->option['recode']['lat_min'] / 60) * $this->option['recode']['ns'];
            $zty = (new Util())->zhenTaiyangShi($yy, $mm, $dd, $hh, $ii, 0, $longitude, $latitude);
            $time = $time + ($longitude - $this->option['recode']['timezone'] * 15) * 4 * 60;
            try
            {
                $this->data['birth_time'] = strtotime($zty[0] . '-' . $zty[1] . '-' . $zty[2] . ' ' . $zty[3] . ':' . $zty[4]);
                $shichen = [
                    1 => [1, 3],
                    2 => [3, 5],
                    3 => [5, 7],
                    4 => [7, 9],
                    5 => [9, 11],
                    6 => [11, 13],
                    7 => [13, 15],
                    8 => [15, 17],
                    9 => [17, 19],
                    10 => [19, 21],
                    11 => [21, 23],
                ];
                $bjsj = 0;
                $ztysj = 0;
                foreach ($shichen as $k => $v)
                {
                    if ($hh >= $v[0] && $hh < $v[1])
                    {
                        $bjsj = $k;
                    }
                    if ($zty[3] >= $v[0] && $zty[3] < $v[1])
                    {
                        $ztysj = $k;
                    }
                }
                // 判断是否需要提示真太阳时对生辰信息产生了影响
                if ($bjsj !== $ztysj)
                {
                    $this->data['is_need_show_tip'] = 1;
                }
            }
            catch (Exception $e)
            {
                Log::write('紫微真太阳时处理失败:' . $e->getMessage() . ' [' . $e->getFile() . ':' . $e->getLine() . ']');
                // 平太阳时
                $this->data['birth_time'] = $time;
            }
//            $longitude = ($this->option['recode']['long_deg'] + $this->option['recode']['long_min'] / 60) * $this->option['recode']['ew'];
//            $this->data['birth_time'] = $time + ($longitude - $this->option['recode']['timezone'] * 15) * 4 * 60;
//            $time = $this->data['birth_time'];
        }// 默认使用北京时间 把用户时间转换成北京时间
        else
        {
            $time += (8 - $this->option['recode']['timezone']) * 3600;
        }

        $year = date('Y', $time) * 1;
        $month = date('m', $time) * 1;
        $hour = (int)(date('H', $time));

        $year_stem_branche = $this->getYearStemBranche($year);

        if ($month < 3 && $sunDeg < 315)
        {
            $year_stem_branche--;

            if ($year_stem_branche < 0) $year_stem_branche = 59;
        }

        $bazi_str = $chinese_era[$year_stem_branche];
        // 每15度一个节气   总共二十四节气  月令地支
        $month_branche = ["卯", "辰", "辰", "巳", "巳", "午", "午", "未", "未", "申", "申", "酉", "酉", "戌", "戌", "亥", "亥", "子", "子", "丑", "丑", "寅", "寅", "卯"];

        $temp = ["寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥", "子", "丑"];// 十二个月

        // $temp2 = ["丙","戊","庚","壬","甲","丙","戊","庚","壬","甲"];
        $temp2 = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0];

        $month_branche_num = (int)(floor($sunDeg / 15));// 向下取整

        $month_branche_str = $month_branche[$month_branche_num];// 月令地支

        $year_stem = mb_substr($bazi_str, 0, 1, 'utf-8');

        $year_num = array_search($year_stem, $Heavenly_Stems);

        $start_num = $temp2[$year_num];

        $month_branche_num = array_search($month_branche_str, $temp);

        $newArr = array_merge($Heavenly_Stems, $Heavenly_Stems, $Heavenly_Stems);

        $s = [];

        for ($i = $start_num; $i < $start_num + 12; $i++) $s[] = $newArr[$i];

        $month_stem_branche = $s[$month_branche_num] . $month_branche_str;

        $time2 = 941990400;

        $time1 = strtotime(date('Y-m-d', $time));
        // 日辰初始默认使用24点
        $val = ($time1 - $time2) / 3600 / 24 % 60;

        // 日辰初始使用23点
        if ($getHour && $this->option['time_start'] == 23 && $hour == 23)
        {
            $val++;
            if ($val == 60) $val = 0;
        }

        $day_stem_branche = $val < 0 ? $val + 60 : $val;

        $bazi_str .= $month_stem_branche;

        $bazi_str .= $chinese_era[$day_stem_branche];

        $bazi = [
            1 => mb_substr($bazi_str, 0, 1, 'utf8'),
            2 => mb_substr($bazi_str, 1, 1, 'utf8'),
            3 => mb_substr($bazi_str, 2, 1, 'utf8'),
            4 => mb_substr($bazi_str, 3, 1, 'utf8'),
            5 => mb_substr($bazi_str, 4, 1, 'utf8'),
            6 => mb_substr($bazi_str, 5, 1, 'utf8'),
        ];

        if ($getHour)
        {
            // 二十四小时，十二个时辰  时辰地支
            $hour_branche = ["子", "丑", "丑", "寅", "寅", "卯", "卯", "辰", "辰", "巳", "巳", "午", "午", "未", "未", "申", "申", "酉", "酉", "戌", "戌", "亥", "亥", "子"];

            // $temp2 = ["甲","丙","戊","庚","壬","甲","丙","戊","庚","壬"];
            $temp2 = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8];

            $hour_branche_str = $hour_branche[$hour];// 时辰地支

            $day_stem_branche = mb_substr($chinese_era[$day_stem_branche], 0, 1, 'utf-8');

            $day_num = array_search($day_stem_branche, $Heavenly_Stems);

            // 若日辰初始为24点，且为晚子时（23～0点之间，包含0点），则晚子时的人往下推一天
            if ($this->option['time_start'] != 23 && $hour == 23)
            {
                $day_num++;
                // 溢出处理
                if ($day_num === 10)
                {
                    $day_num = 0;
                }
            }
            $start_num = $temp2[$day_num];

            $hour_branche_num = array_search($hour_branche_str, $Earthly_Branches);

            $newArr = array_merge($Heavenly_Stems, $Heavenly_Stems, $Heavenly_Stems);

            $s = [];
            for ($i = $start_num; $i < $start_num + 12; $i++)
            {
                $s[] = $newArr[$i];
            }

            $bazi_str .= $s[$hour_branche_num] . $hour_branche_str;

            $bazi[7] = mb_substr($bazi_str, 6, 1, 'utf8');
            $bazi[8] = mb_substr($bazi_str, 7, 1, 'utf8');
        }

        $this->data['bazi'] = $bazi;

        return $bazi;
    }

    /**
     * 获取年干支
     * @param null $year
     * @return int
     */
    public function getYearStemBranche($year = null)
    {
        return ($year - 4) % 60 < 0 ? ($year - 4) % 60 + 60 : ($year - 4) % 60;
    }

    /**
     * 获取起运时间
     */
    public function dayun()
    {
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 六十甲子
        $chinese_era = $this->param['chinese_era'];

        $num = array_search($this->data['bazi'][1], $Heavenly_Stems);

        $this->option['recode']['timezone'] = isset($this->option['recode']['timezone']) ? $this->option['recode']['timezone'] : 8;

        $this->option['recode']['is_summer'] = isset($this->option['recode']['is_summer']) ? $this->option['recode']['is_summer'] : 0;

        $this->option['recode']['type'] *= 1;

        $birth_day_time_0 = $this->data['birth_time'] - ($this->option['recode']['timezone'] * 3600
                + 3600 * $this->option['recode']['is_summer']);

        // 阳男 || 阴女 六十甲子顺行 下一个节令时间 （节令黄经度数 为15°的奇数倍数）
        if (($num % 2 == 0 && $this->option['recode']['type'] == 1)
            || ($num % 2 == 1 && $this->option['recode']['type'] == 2))
        {
            $r = false;// 阳男 || 阴女  顺推

            $luck_time = (new SolarTerms())->getTremTime(['time' => $birth_day_time_0, 'sort' => 'asc']);

        } // 阴男 || 阳女 六十甲子逆行  上一个节令时间 （节令黄经度数 为15°的奇数倍数）
        else
        {
            $r = true;// 阴男 || 阳女 逆推

            $luck_time = (new SolarTerms())->getTremTime(['time' => $birth_day_time_0, 'sort' => 'desc']);
        }

        $diff_year = abs($birth_day_time_0 - $luck_time) / 3600 / 24 / 3;

        $st_time = $this->data['birth_time'] + $diff_year * 365 * 24 * 3600;

        // 大运
        $yuezhu = $this->data['bazi'][3] . $this->data['bazi'][4];
        $dayun_bazi_array = array_merge($chinese_era, $chinese_era, $chinese_era);

        if ($r === true)
        {
            $all = array_reverse($dayun_bazi_array);
            $this->data['dayun'] = array_slice($all, array_search($yuezhu, $all, true) + 1, 60);
        } else
        {
            $this->data['dayun'] = array_slice($dayun_bazi_array, array_search($yuezhu, $dayun_bazi_array, true) + 1, 60);
        }

        $this->data['st_time'] = $st_time;
        return;
    }

    /**
     * 获取起运时间带小运版本
     */
    public function dayun2()
    {
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 六十甲子
        $chinese_era = $this->param['chinese_era'];

        $num = array_search($this->data['bazi'][1], $Heavenly_Stems);

        $this->option['recode']['timezone'] = isset($this->option['recode']['timezone']) ? $this->option['recode']['timezone'] : 8;

        $this->option['recode']['is_summer'] = isset($this->option['recode']['is_summer']) ? $this->option['recode']['is_summer'] : 0;

        $this->option['recode']['type'] *= 1;

        $birth_day_time_0 = $this->data['birth_time'] - ($this->option['recode']['timezone'] * 3600 + 3600 * $this->option['recode']['is_summer']);

        // 阳男 || 阴女 六十甲子顺行 下一个节令时间 （节令黄经度数 为15°的奇数倍数）
        if (($num % 2 == 0 && $this->option['recode']['type'] == 1)
            || ($num % 2 == 1 && $this->option['recode']['type'] == 2))
        {
            $r = false;// 阳男 || 阴女  顺推

            $luck_time = (new SolarTerms())->getTremTime(['time' => $birth_day_time_0, 'sort' => 'asc']);

        } // 阴男 || 阳女 六十甲子逆行  上一个节令时间 （节令黄经度数 为15°的奇数倍数）
        else
        {
            $r = true;// 阴男 || 阳女 逆推

            $luck_time = (new SolarTerms())->getTremTime(['time' => $birth_day_time_0, 'sort' => 'desc']);
        }
        $diff_year = abs($birth_day_time_0 - $luck_time) / 3600 / 24 / 3;
        $st_time = $this->data['birth_time'] + $diff_year * 365 * 24 * 3600;
        // 大运 从月柱起
        $yuezhu = $this->data['bazi'][3] . $this->data['bazi'][4];
        // 小运 从时柱起
        $shizhu = $this->data['bazi'][7] . $this->data['bazi'][8];
        $dayun_bazi_array = array_merge($chinese_era, $chinese_era, $chinese_era);
//        $xiaoyunNum = floor($diff_year); // 由于部分小运年缺失年份，所以废弃
        // 使用大运起运年份减去档案出生的年份，表示小运一共有几年
        $xiaoyunNum = date('Y', floor($st_time)) - $this->option['recode']['year'];
        if ($xiaoyunNum < 1)
        {
            $xiaoyunNum = 1;
        }

        if ($r === true)
        {
            $all = array_reverse($dayun_bazi_array);
            $this->data['dayun'] = array_slice($all, array_search($yuezhu, $all, true) + 1, 9);
            // 从时柱出发，阳男阴女顺排，阴男阳女逆排 从出生年起，排1位
            $this->data['xiaoyun'] = array_slice($all, array_search($shizhu, $all, true) + 1, $xiaoyunNum);
        } else
        {
            $this->data['dayun'] = array_slice($dayun_bazi_array, array_search($yuezhu, $dayun_bazi_array, true) + 1, 9);
            // 从时柱出发，阳男阴女顺排，阴男阳女逆排 从出生年起，排1位
            $this->data['xiaoyun'] = array_slice($dayun_bazi_array, array_search($shizhu, $dayun_bazi_array, true) + 1, $xiaoyunNum);
        }

        $this->data['st_time'] = $st_time;
        return;
    }

    /**
     * 获取八字十神关系
     * @return array
     */
    public function getShishen()
    {
        $config_shishen = $this->param['shishen'];
        $config_canggan = $this->param['canggan'];
        $shishen = [];
        for ($i = 1; $i < 9; $i++)
        {
            if ($i == 5) continue;
            $rigan = $this->data['bazi'][5];
            $other = $this->data['bazi'][$i];
//            $loc = ceil($i / 2);
            // 干
            if ($i % 2 == 1)
            {
                $shishen['gan'][$i] = [
                    'a' => $rigan,
                    'b' => $other,
                    'relation' => $config_shishen[$other][$rigan],
                    'loc' => $i,
                ];
            } // 藏干
            else
            {
                foreach ($config_canggan[$other] as $k => $g)
                {
                    $benqi = $k === 0 ? true : false;
                    $shishen['cang'][$i][] = [
                        'a' => $rigan,
                        'b' => $other,
                        'relation' => $config_shishen[$g][$rigan],
                        'loc' => $i,
                        'benqi' => $benqi,
                    ];
                }
            }
        }
        return $shishen;
    }

    /**
     * 获取当前八字神煞关系
     * @return array
     */
    public function getShensha($bazi = [], $dayun = [], $liunian = [])
    {
        $res = [[], [], [], [], [], []];
        // 神煞，简单模式包括 天乙贵人，驿马，天德贵人，华盖，将星，桃花（咸池），详细模式展示所有
        // 八字中的所有天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 八字中的所有地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        // 添加大运天干地支
        $tiangan[] = $dayun[0];
        $dizhi[] = $dayun[1];
        // 添加流年天干地支
        $tiangan[] = $liunian[0];
        $dizhi[] = $liunian[1];
        $shensha = $this->param['shensha'];
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        $num = array_search($bazi[1], $Heavenly_Stems, true);
        if (($num % 2 == 0 && $this->option['recode']['type'] == 1)
            || ($num % 2 == 1 && $this->option['recode']['type'] == 2))
        {
            $r = 0;// 阳男 || 阴女  顺推
        } else
        {
            $r = 1;// 阴男 || 阳女 逆推
        }
        // 原局4柱+大运/小运+流年
        for ($i = 0; $i < 6; $i++)
        {
            // 简单模式只计算以下六个
            // 天乙贵人 以年干或日干为参照，老规则(年干查不可查年支)
            $g = '天乙贵人';
            if (($i > 0 && in_array($dizhi[$i], $shensha[$g][$tiangan[0]], true))
                || in_array($dizhi[$i], $shensha[$g][$tiangan[2]], true))
            {
                $res[$i][] = $g;
            }
            // 天德贵人 以月支为参照，查找日柱和时柱
            $g = '天德贵人';
            if (in_array($i, [2, 3], true) && $shensha[$g][$dizhi[1]] === $tiangan[$i])
            {
                $res[$i][] = $g;
            }
            // 驿马 以年支或日支为参照，老规则
            $g = '驿马';
            if ($shensha[$g][$dizhi[0]] === $dizhi[$i]
                || $shensha[$g][$dizhi[2]] === $dizhi[$i])
            {
                $res[$i][] = $g;
            }
            // 华盖 以年支或日支为参照，老规则(不可查找参照支)
            $g = '华盖';
            if (($i !== 0 && $shensha[$g][$dizhi[0]] === $dizhi[$i])
                || ($i !== 2 && $shensha[$g][$dizhi[2]] === $dizhi[$i]))
            {
                $res[$i][] = $g;
            }
            // 将星 以年支或日支为参照，老规则(不可查找参照支)
            $g = '将星';
            if (($i !== 0 && $shensha[$g][$dizhi[0]] === $dizhi[$i])
                || ($i !== 2 && $shensha[$g][$dizhi[2]] === $dizhi[$i]))
            {
                $res[$i][] = $g;
            }
            // 桃花 以年支或日支为参照，老规则
            $g = '桃花';
            if ($shensha[$g][$dizhi[0]] === $dizhi[$i]
                || $shensha[$g][$dizhi[2]] === $dizhi[$i])
            {
                $res[$i][] = $g;
            }

            // 计算详细版的神煞
            if ($this->option['shensha'] === 2)
            {
                // 文昌贵人 以年干或日干为参照，查找四个地支（年干查找时略去年支）
                $g = '文昌贵人';
                if (($i > 0 && $shensha[$g][$tiangan[0]] === $dizhi[$i])
                    || $shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 月德贵人 以月支为参照，查找日柱和时柱
                $g = '月德贵人';
                if (in_array($i, [2, 3], true) && $shensha[$g][$dizhi[1]] === $tiangan[$i])
                {
                    $res[$i][] = $g;
                }
                // 金舆 以年干或日干为参照，老规则(年干查不可查年支)
                $g = '金舆';
                if (($i > 0 && $shensha[$g][$tiangan[0]] === $dizhi[$i])
                    || $shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 劫煞 以年支或日支为参照
                $g = '劫煞';
                if ($shensha[$g][$dizhi[0]] === $dizhi[$i]
                    || $shensha[$g][$dizhi[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 亡神 以年支或日支为参照
                $g = '亡神';
                if ($shensha[$g][$dizhi[0]] === $dizhi[$i]
                    || $shensha[$g][$dizhi[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 魁罡 查找四柱，出现以下柱即为魁罡
                $g = '魁罡';
                if (in_array($tiangan[$i] . $dizhi[$i], $shensha[$g], true))
                {
                    $res[$i][] = $g;
                }
                // 金神 查找日时(1、日柱为乙丑或己巳或癸酉；2、时柱为乙丑或己巳或癸酉且日干是甲或己)
                $g = '金神';
                if (($i === 2 && in_array($tiangan[$i] . $dizhi[$i], $shensha[$g], true))
                    || ($i === 3 && in_array($tiangan[$i] . $dizhi[$i], $shensha[$g], true)
                        && in_array($tiangan[2], ['甲', '乙'], true)))
                {
                    $res[$i][] = $g;
                }
                // 禄神 日干为参照
                $g = '禄神';
                if ($shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 羊刃 日干为参照
                $g = '羊刃';
                if ($shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 灾煞 以年支或日支为参照
                $g = '灾煞';
                if ($shensha[$g][$dizhi[0]] === $dizhi[$i]
                    || $shensha[$g][$dizhi[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 词馆 以年干或日干为参照
                $g = '词馆';
                if ($shensha[$g][$tiangan[0]] === ($tiangan[$i] . $dizhi[$i])
                    || $shensha[$g][$tiangan[2]] === ($tiangan[$i] . $dizhi[$i]))
                {
                    $res[$i][] = $g;
                }
                // 学堂 以年柱或日柱纳音五行为参照
                $nianNayin = $this->getNayin($tiangan[0], $dizhi[0]);
                $nianNayinWuxing = mb_substr($nianNayin, 2, 1);
                $riNayin = $this->getNayin($tiangan[2], $dizhi[2]);
                $riNayinWuxing = mb_substr($riNayin, 2, 1);
                $g = '学堂';
                if ($shensha[$g][$nianNayinWuxing] === $dizhi[$i]
                    || $shensha[$g][$riNayinWuxing] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 孤辰 以年支为参照
                $g = '孤辰';
                if ($shensha[$g][$dizhi[0]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 寡宿 以年支为参照
                $g = '寡宿';
                if ($shensha[$g][$dizhi[0]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 国印 以年干或日干为参照
                $g = '国印';
                if ($shensha[$g][$tiangan[0]] === $dizhi[$i]
                    || $shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 太极贵人 以年干或日干为参照
                $g = '太极贵人';
                if (in_array($dizhi[$i], $shensha[$g][$tiangan[0]], true)
                    || in_array($dizhi[$i], $shensha[$g][$tiangan[2]], true))
                {
                    $res[$i][] = $g;
                }
                // 天德合 以月支为参照，查找日柱和时柱
                $g = '天德合';
                if (in_array($i, [2, 3], true) && $shensha[$g][$dizhi[1]] === $tiangan[$i])
                {
                    $res[$i][] = $g;
                }
                // 月德合 以月支为参照，查找日柱和时柱
                $g = '月德合';
                if (in_array($i, [2, 3], true) && $shensha[$g][$dizhi[1]] === $tiangan[$i])
                {
                    $res[$i][] = $g;
                }
                // 德秀贵人 以月支为参照，查找四天干(一德一秀，必须德秀都有才是，比如寅午戌，丙丁为德，戊癸为秀，丙丁之一和戊癸之一要同见)
                $g = '德秀贵人';
                if (in_array($tiangan[$i], $shensha[$g][$dizhi[1]][0], true))
                {
                    // 当前天干为德
                    for ($j = 0; $j < 6; $j++)
                    {
                        if ($i === $j) continue;
                        // 其他天干中有秀
                        if (in_array($tiangan[$j], $shensha[$g][$dizhi[1]][1], true))
                        {
                            $res[$i][] = $g;
                            break;
                        }
                    }
                } elseif (in_array($tiangan[$i], $shensha[$g][$dizhi[1]][1], true))
                {
                    // 当前天干为秀
                    for ($j = 0; $j < 6; $j++)
                    {
                        if ($i === $j) continue;
                        // 其他天干中有德
                        if (in_array($tiangan[$j], $shensha[$g][$dizhi[1]][0], true))
                        {
                            $res[$i][] = $g;
                            break;
                        }
                    }
                }
                // 红艳 以日干为参照
                $g = '红艳';
                if ($shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 流霞 以日干为参照
                $g = '流霞';
                if ($shensha[$g][$tiangan[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 元辰 以年支为参照(区分阳男阴女 || 阴男阳女)
                $g = '元辰';
                if ($shensha[$g][$r][$dizhi[0]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 六厄 以年支或日支为参照
                $g = '六厄';
                if ($shensha[$g][$dizhi[0]] === $dizhi[$i]
                    || $shensha[$g][$dizhi[2]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 天医 以月支为参照，查其它地支
                $g = '天医';
                if ($i !== 1 && $shensha[$g][$dizhi[1]] === $dizhi[$i])
                {
                    $res[$i][] = $g;
                }
                // 五行正印 以年柱或日柱纳音五行为参照，查其它柱
                $g = '五行正印';
                if (($i !== 0 && $shensha[$g][$nianNayinWuxing] === ($tiangan[$i] . $dizhi[$i]))
                    || ($i !== 2 && $shensha[$g][$riNayinWuxing] === ($tiangan[$i] . $dizhi[$i])))
                {
                    $res[$i][] = $g;
                }
            }
        }
        return $res;
    }

    /**
     * 华盖
     * @return array
     */
    private function huagai()
    {
        $ret = [];
        $name = '华盖';
        if ($this->is_huagai($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_huagai($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 桃花
     * @return array
     */
    private function taohua()
    {
        $ret = [];
        $name = '桃花';
        if ($this->is_taohua($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_taohua($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 驿马
     * @return array
     */
    private function yima()
    {
        $ret = [];
        $name = '驿马';
        if ($this->is_yima($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_yima($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_yima($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_yima($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_yima($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_yima($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 亡神
     * @return array
     */
    private function wangshen()
    {
        $ret = [];
        $name = '亡神';
        if ($this->is_wangshen($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_wangshen($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 劫煞
     * @return array
     */
    private function jiesha()
    {
        $ret = [];
        $name = '劫煞';
        if ($this->is_jiesha($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiesha($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 将星
     * @return array
     */
    private function jiangxing()
    {
        $ret = [];
        $name = '将星';
        if ($this->is_jiangxing($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jiangxing($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 灾煞
     * @return array
     */
    private function zaisha()
    {
        $ret = [];
        $name = '灾煞';
        if ($this->is_zaisha($this->data['bazi'][6], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][6], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 6,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][6], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][6], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][2], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_zaisha($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2], $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 天乙贵人
     * @return array
     */
    private function tianyiguiren()
    {
        $ret = [];
        $name = '天乙贵人';
        if ($this->is_tianyiguiren($this->data['bazi'][1], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][1] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][1], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][1] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '月支',
                'location_num' => 2,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_tianyiguiren($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 天德贵人
     * @return array
     */
    private function tiandeguiren()
    {
        $ret = [];
        $name = '天德贵人';
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][5]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][5],
                'location_cn' => '日干',
                'location_num' => 5,
            ];
        }
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][7]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][7],
                'location_cn' => '时干',
                'location_num' => 7,
            ];
        }
        if ($this->is_tiandeguiren($this->data['bazi'][4], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 文昌贵人
     * @return array
     */
    private function wenchangguiren()
    {
        $ret = [];
        $name = '文昌贵人';
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_wenchangguiren($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 月德贵人
     * @return array
     */
    private function yuedeguiren()
    {
        $ret = [];
        $name = '月德贵人';
        if ($this->is_yuedeguiren($this->data['bazi'][4], $this->data['bazi'][5]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][5],
                'location_cn' => '日干',
                'location_num' => 5,
            ];
        }
        if ($this->is_yuedeguiren($this->data['bazi'][4], $this->data['bazi'][7]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][4] . $this->data['bazi'][7],
                'location_cn' => '时干',
                'location_num' => 7,
            ];
        }
        return $ret;
    }

    /**
     * 金舆
     * @return array
     */
    private function jinyu()
    {
        $ret = [];
        $name = '金舆';
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jinyu($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 红艳煞
     * @return array
     */
    private function hongyansha()
    {
        $ret = [];
        $name = '红艳';
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_hongyansha($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 孤辰
     * @return array
     */
    private function guchen()
    {
        $ret = [];
        $name = '孤辰';
        if ($this->is_guchen($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_guchen($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 寡宿
     * @return array
     */
    private function guaxiu()
    {
        $ret = [];
        $name = '寡宿';
        if ($this->is_guaxiu($this->data['bazi'][2], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_guaxiu($this->data['bazi'][2], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][2] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 禄神
     * @return array
     */
    private function lushen()
    {
        $ret = [];
        $name = '禄神';
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_lushen($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 羊刃
     * @return array
     */
    private function yangren()
    {
        $ret = [];
        $name = '羊刃';
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][2]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][2],
                'location_cn' => '年支',
                'location_num' => 2,
            ];
        }
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][4]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][4],
                'location_cn' => '月支',
                'location_num' => 4,
            ];
        }
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_yangren($this->data['bazi'][5], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 金神
     * @return array
     */
    private function jinshen()
    {
        $ret = [];
        $name = '金神';
        if ($this->is_jinshen($this->data['bazi'][5], $this->data['bazi'][6]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][5] . $this->data['bazi'][6],
                'location_cn' => '日支',
                'location_num' => 6,
            ];
        }
        if ($this->is_jinshen($this->data['bazi'][7], $this->data['bazi'][8]))
        {
            $ret[] = [
                'name' => $name,
                'condition' => $this->data['bazi'][7] . $this->data['bazi'][8],
                'location_cn' => '时支',
                'location_num' => 8,
            ];
        }
        return $ret;
    }

    /**
     * 检查是否为华盖
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_huagai($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['戌', '未', '辰', '丑'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为桃花
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_taohua($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['卯', '子', '酉', '午'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为驿马
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_yima($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['申', '巳', '寅', '亥'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为亡神
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_wangshen($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['巳', '寅', '亥', '申'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为劫煞
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_jiesha($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['亥', '申', '巳', '寅'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为将星
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_jiangxing($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['午', '卯', '子', '酉'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为灾煞
     * @param null $zhi1 日支/年支
     * @param null $zhi2 其他三个地支
     * @return bool
     */
    private function is_zaisha($zhi1 = null, $zhi2 = null)
    {
        $rizhi_nianzhi = [
            ['寅', '午', '戌'],
            ['亥', '卯', '未'],
            ['申', '子', '辰'],
            ['巳', '酉', '丑'],
        ];
        $jian = ['子', '酉', '午', '卯'];
        foreach ($rizhi_nianzhi as $k => $rn) if (in_array($zhi1, $rn) && $zhi2 == $jian[$k]) return true;
        return false;
    }

    /**
     * 检查是否为天乙贵人
     * @param null $gan 年干   /   日干
     * @param null $zhi 日时支  /  四地支
     * @return bool
     */
    public function is_tianyiguiren($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['天乙贵人'];
        if (isset($lx[$gan]) && in_array($zhi, $lx[$gan])) return true;
        else return false;
    }

    /**
     * 检查是否为天德贵人
     * @param null $mzhi
     * @param null $zhi 日时干支
     * @return bool
     */
    private function is_tiandeguiren($mzhi = null, $zhi = null)
    {
        $lx = $this->param['shensha']['天德贵人'];
        if (isset($lx[$mzhi]) && $lx[$mzhi] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为文昌贵人
     * @param null $gan 日干
     * @param null $zhi 地支
     * @return bool
     */
    private function is_wenchangguiren($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['文昌贵人'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为月德贵人
     * @param null $yzhi 月支
     * @param null $zhi 日时干支  壬丙庚甲
     * @return bool
     */
    private function is_yuedeguiren($yzhi = null, $zhi = null)
    {
        $lx = $this->param['shensha']['月德贵人'];
        if (isset($lx[$yzhi]) && $lx[$yzhi] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为金舆
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_jinyu($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['金舆'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为红艳煞
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_hongyansha($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['红艳'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为孤辰
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_guchen($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['孤辰'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为寡宿
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_guaxiu($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['寡宿'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为禄神
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_lushen($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['禄神'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为羊刃
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_yangren($gan = null, $zhi = null)
    {
        $lx = $this->param['shensha']['羊刃'];
        if (isset($lx[$gan]) && $lx[$gan] == $zhi) return true;
        else return false;
    }

    /**
     * 检查是否为金神
     * $gan $zhi 为日干支  ||  时干支   组合
     * @param null $gan
     * @param null $zhi
     * @return bool
     */
    private function is_jinshen($gan = null, $zhi = null)
    {
        $ganzhi = $gan . $zhi;
        $lx = $this->param['shensha']['金神'];
        foreach ($lx as $x) if ($x == $ganzhi) return true;
        return false;
    }

    /**
     * 天干五合
     * 甲己相合为土，乙庚相合为金，丙辛相合为水，丁壬相合为木，戊癸相合为火。
     * @param null $gan1
     * @param null $gan2
     * @return bool
     */
    public function is_wuhe($gan1 = null, $gan2 = null)
    {
        if (($gan1 == '甲' && $gan2 == '己') || ($gan1 == '己' && $gan2 == '甲'))
        {
            return true;
        } elseif (($gan1 == '乙' && $gan2 == '庚') || ($gan1 == '庚' && $gan2 == '乙'))
        {
            return true;
        } elseif (($gan1 == '丙' && $gan2 == '辛') || ($gan1 == '辛' && $gan2 == '丙'))
        {
            return true;
        } elseif (($gan1 == '丁' && $gan2 == '壬') || ($gan1 == '壬' && $gan2 == '丁'))
        {
            return true;
        } elseif (($gan1 == '戊' && $gan2 == '癸') || ($gan1 == '癸' && $gan2 == '戊'))
        {
            return true;
        }
        return false;
    }

    /**
     * 检查地支是否六合
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liuhe($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $liuhe = ['子丑', '寅亥', '卯戌', '辰酉', '巳申', '午未'];
        foreach ($liuhe as $lh)
        {
            if ($zhi1 . $zhi2 == $lh || $zhi2 . $zhi1 == $lh)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否暗合
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_anhe($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $anhe = ['卯申', '午亥', '巳酉'];
        foreach ($anhe as $lh)
        {
            if ($zhi1 . $zhi2 == $lh || $zhi2 . $zhi1 == $lh)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否六冲
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liuchong($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $liuchong = ['子午', '丑未', '寅申', '卯酉', '辰戌', '巳亥'];
        foreach ($liuchong as $lc)
        {
            if (is_array($zhi2) && !empty($zhi2))
            {
                foreach ($zhi2 as $z2)
                {
                    if ($zhi1 . $z2 == $lc || $z2 . $zhi1 == $lc)
                    {
                        return true;
                    }
                }
            } else
            {
                if ($zhi1 . $zhi2 == $lc || $zhi2 . $zhi1 == $lc)
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 检查地支是否六害
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liuhai($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $liuhai = ['子未', '丑午', '寅巳', '卯辰', '申亥', '酉戌'];
        foreach ($liuhai as $lh)
        {
            if (is_array($zhi2) && !empty($zhi2))
            {
                foreach ($zhi2 as $z2)
                {
                    if ($zhi1 . $z2 == $lh || $z2 . $zhi1 == $lh)
                    {
                        return true;
                    }
                }
            } else
            {
                if ($zhi1 . $zhi2 == $lh || $zhi2 . $zhi1 == $lh)
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 检查地支是否拱
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_gong($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 == $zhi2) return false;
        $gong = [['申', '子', '辰'], ['寅', '午', '戌'], ['亥', '卯', '未'], ['巳', '酉', '丑']];// 水 火 木 金
        foreach ($gong as $g)
        {
            if (in_array($zhi1, $g) && in_array($zhi2, $g))
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否六破
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_liupo($zhi1 = null, $zhi2 = null): bool
    {
        if (!$zhi1 || !$zhi2 || $zhi1 === $zhi2) return false;
        $liupo = ['寅亥', '巳申', '子酉', '午卯', '戌未', '丑辰'];
        foreach ($liupo as $lp)
        {
            if ($zhi1 . $zhi2 === $lp || $zhi2 . $zhi1 === $lp)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否三会
     * @param null $zhi1
     * @param null $zhi2
     * @param null $zhi3
     * @return string
     */
    private function is_sanhui($zhi1 = null, $zhi2 = null, $zhi3 = null)
    {
        if (!$zhi1 || !$zhi2 || !$zhi3 || $zhi1 === $zhi2 || $zhi1 === $zhi3 || $zhi2 === $zhi3) return '';
        $sanhui = ['亥子丑', '寅卯辰', '巳午未', '申酉戌'];// 水 木 火 金
        $wx = ['水', '木', '火', '金'];
        foreach ($sanhui as $k => $sh)
        {
            if (
                $zhi1 . $zhi2 . $zhi3 === $sh
                || $zhi1 . $zhi3 . $zhi2 === $sh
                || $zhi2 . $zhi1 . $zhi3 === $sh
                || $zhi2 . $zhi3 . $zhi1 === $sh
                || $zhi3 . $zhi1 . $zhi2 === $sh
                || $zhi3 . $zhi2 . $zhi1 === $sh
            )
            {
                return $wx[$k];
            }
        }
        return '';
    }

    /**
     * 检查地支是否三刑
     *  寅巳申三刑 寅刑巳，巳刑申，申刑寅
     *  丑未戌三刑 丑刑戌，戌刑未，未刑丑
     * @param null $zhi1
     * @param null $zhi2
     * @param null $zhi3
     * @return bool
     */
    private function is_sanxing($zhi1 = null, $zhi2 = null, $zhi3 = null): bool
    {
        if (!$zhi1 || !$zhi2 || $zhi1 === $zhi2 || $zhi1 === $zhi3 || $zhi2 === $zhi3) return false;
        $sanxing = ['寅巳申', '丑未戌']; // 子卯
        foreach ($sanxing as $sx)
        {
            if ($zhi1 . $zhi2 . $zhi3 === $sx
                || $zhi1 . $zhi3 . $zhi2 === $sx
                || $zhi2 . $zhi1 . $zhi3 === $sx
                || $zhi2 . $zhi3 . $zhi1 === $sx
                || $zhi3 . $zhi1 . $zhi2 === $sx
                || $zhi3 . $zhi2 . $zhi1 === $sx)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否三合
     * @param null $zhi1
     * @param null $zhi2
     * @param null $zhi3
     * @return string
     */
    public function is_sanhe($zhi1 = null, $zhi2 = null, $zhi3 = null): string
    {
        // 地支同时有寅午戌（火）、申子辰（水）、巳酉丑（金）、亥卯未（木）
        if (!$zhi1 || !$zhi2 || $zhi1 === $zhi2 || $zhi1 === $zhi3 || $zhi2 === $zhi3) return '';
        $sanhe = ['寅午戌', '申子辰', '巳酉丑', '亥卯未'];// 火 水 金 木
        $wx = ['火', '水', '金', '木'];
        foreach ($sanhe as $k => $sh)
        {
            if (
                $zhi1 . $zhi2 . $zhi3 === $sh
                || $zhi1 . $zhi3 . $zhi2 === $sh
                || $zhi2 . $zhi1 . $zhi3 === $sh
                || $zhi2 . $zhi3 . $zhi1 === $sh
                || $zhi3 . $zhi1 . $zhi2 === $sh
                || $zhi3 . $zhi2 . $zhi1 === $sh
            )
            {
                return $wx[$k];
            }
        }
        return '';
    }

    /**
     * 检查地支是否刑
     * 丑未为六冲  寅申为六冲  巳申为六合 排除这三种
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    public function is_xing($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 === $zhi2 || (in_array($zhi1, ['丑', '未']) && in_array($zhi2, ['丑', '未']))) return false;
        $xing = [['寅', '巳'], ['丑', '戌', '未']];
        foreach ($xing as $x)
        {
            if (in_array($zhi1, $x, true) && in_array($zhi2, $x, true))
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 检查地支是否自刑
     * @param null $zhi1
     * @param null $zhi2
     * @return bool
     */
    private function is_zixing($zhi1 = null, $zhi2 = null)
    {
        if (!$zhi1 || !$zhi2 || $zhi1 !== $zhi2) return false;
        $zixing = ['辰', '午', '酉', '亥'];
        foreach ($zixing as $zx)
        {
            if ($zhi1 === $zx)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 盖头
     * 天干克地支（同柱）
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return bool
     */
    private function is_gaitou($gan = null, $zhi = null)
    {
        if (!$gan || !$zhi) return false;

        $gaitou = ['甲辰', '甲戌', '乙丑', '乙未', '丙申', '丁酉', '戊亥', '己子', '庚寅', '辛卯', '壬巳', '癸午'];

        if (in_array($gan . $zhi, $gaitou))
        {
            return true;
        }
        return false;
    }

    /**
     * 截脚
     * 地支克天干（同柱）
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return bool
     */
    private function is_jiejiao($gan = null, $zhi = null)
    {
        if (!$gan || !$zhi || mb_strlen($gan) != 1 || mb_strlen($zhi) != 1) return false;

        $jiejiao = ['甲申', '乙酉', '丙亥', '丁子', '戊寅', '己卯', '庚巳', '辛午', '壬辰', '壬戌', '癸丑', '癸未'];

        if (in_array($gan . $zhi, $jiejiao))
        {
            return true;
        }
        return false;
    }

    /**
     * 纳音关系
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return string
     */
    private function getNayin($gan = null, $zhi = null)
    {
        $nayin = '';
        switch ($gan . $zhi)
        {
            case '甲子':
            case '乙丑':
                $nayin = '海中金';
                break;
            case '丙寅':
            case '丁卯':
                $nayin = '炉中火';
                break;
            case '戊辰':
            case '己巳':
                $nayin = '大林木';
                break;
            case '庚午':
            case '辛未':
                $nayin = '路旁土';
                break;
            case '壬申':
            case '癸酉':
                $nayin = '剑锋金';
                break;
            case '甲戌':
            case '乙亥':
                $nayin = '山头火';
                break;
            case '丙子':
            case '丁丑':
                $nayin = '涧下水';
                break;
            case '戊寅':
            case '己卯':
                $nayin = '城头土';
                break;
            case '庚辰':
            case '辛巳':
                $nayin = '白蜡金';
                break;
            case '壬午':
            case '癸未':
                $nayin = '杨柳木';
                break;
            case '甲申':
            case '乙酉':
                $nayin = '井泉水';
                break;
            case '丙戌':
            case '丁亥':
                $nayin = '屋上土';
                break;
            case '戊子':
            case '己丑':
                $nayin = '霹雳火';
                break;
            case '庚寅':
            case '辛卯':
                $nayin = '松柏木';
                break;
            case '壬辰':
            case '癸巳':
                $nayin = '长流水';
                break;
            case '甲午':
            case '乙未':
                $nayin = '砂中金';
                break;
            case '丙申':
            case '丁酉':
                $nayin = '山下火';
                break;
            case '戊戌':
            case '己亥':
                $nayin = '平地木';
                break;
            case '庚子':
            case '辛丑':
                $nayin = '壁上土';
                break;
            case '壬寅':
            case '癸卯':
                $nayin = '金箔金';
                break;
            case '甲辰':
            case '乙巳':
                $nayin = '覆灯火';
                break;
            case '丙午':
            case '丁未':
                $nayin = '天河水';
                break;
            case '戊申':
            case '己酉':
                $nayin = '大驿土';
                break;
            case '庚戌':
            case '辛亥':
                $nayin = '钗钏金';
                break;
            case '壬子':
            case '癸丑':
                $nayin = '桑柘木';
                break;
            case '甲寅':
            case '乙卯':
                $nayin = '大溪水';
                break;
            case '丙辰':
            case '丁巳':
                $nayin = '砂中土';
                break;
            case '戊午':
            case '己未':
                $nayin = '天上火';
                break;
            case '庚申':
            case '辛酉':
                $nayin = '石榴木';
                break;
            case '壬戌':
            case '癸亥':
                $nayin = '大海水';
                break;
            default:
                break;
        }
        return $nayin;
    }

    /**
     * 空亡
     * @param null $gan 天干
     * @param null $zhi 地支
     * @return string
     */
    private function getKongwang($gan = null, $zhi = null)
    {
        $kongwang = '';
        $ganzhi = $gan . $zhi;
        if (in_array($ganzhi, ['甲子', '乙丑', '丙寅', '丁卯', '戊辰', '己巳', '庚午', '辛未', '壬申', '癸酉']))
        {
            $kongwang = '戌亥';
        } elseif (in_array($ganzhi, ['甲戌', '乙亥', '丙子', '丁丑', '戊寅', '己卯', '庚辰', '辛巳', '壬午', '癸未']))
        {
            $kongwang = '申酉';
        } elseif (in_array($ganzhi, ['甲申', '乙酉', '丙戌', '丁亥', '戊子', '己丑', '庚寅', '辛卯', '壬辰', '癸巳']))
        {
            $kongwang = '午未';
        } elseif (in_array($ganzhi, ['甲午', '乙未', '丙申', '丁酉', '戊戌', '己亥', '庚子', '辛丑', '壬寅', '癸卯']))
        {
            $kongwang = '辰巳';
        } elseif (in_array($ganzhi, ['甲辰', '乙巳', '丙午', '丁未', '戊申', '己酉', '庚戌', '辛亥', '壬子', '癸丑']))
        {
            $kongwang = '寅卯';
        } elseif (in_array($ganzhi, ['甲寅', '乙卯', '丙辰', '丁巳', '戊午', '己未', '庚申', '辛酉', '壬戌', '癸亥']))
        {
            $kongwang = '子丑';
        }
        return $kongwang;
    }

    /**
     * 十神关系  转化为单字显示
     * @param string $relation
     * @return string
     */
    private function shishenToEasy($relation = '')
    {
        switch ($relation)
        {
            case '正财':
                return '财';
            case '偏财':
                return '才';
            case '正印':
                return '印';
            case '偏印':
                return '枭';
            case '食神':
                return '食';
            case '伤官':
                return '伤';
            case '比肩':
                return '比';
            case '劫财':
                return '劫';
            case '七杀':
                return '杀';
            case '正官':
                return '官';
            default:
                return '';
        }
    }

    /**
     * 判断两天干 十神关系
     * @param null $gan1 天干1
     * @param null $gan2 天干2 一般为日干
     * @param null $rela 关系  印 官杀 财 比劫 食伤
     * @return bool
     */
    private function is_ygs($gan1 = null, $gan2 = null, $rela = null)
    {
        if (!$gan1 || !$gan2 || !$rela) return false;

        $temp = $this->param['shishen'][$gan1][$gan2];

        if ($rela == '印' && ($temp == '正印' || $temp == '偏印'))
        {
            return true;
        } elseif ($rela == '官杀' && ($temp == '七杀' || $temp == '正官'))
        {
            return true;
        } elseif ($rela == '财' && ($temp == '正财' || $temp == '偏财'))
        {
            return true;
        } elseif ($rela == '比劫' && ($temp == '比肩' || $temp == '劫财'))
        {
            return true;
        } elseif ($rela == '食伤' && ($temp == '食神' || $temp == '伤官'))
        {
            return true;
        }
        return false;
    }

    /**
     * 身旺/身弱
     * 本命或大运地支 有日干本气比劫
     * 本命或大运地支 有本气正偏印两个以上，且日干有根
     * 本命或大运天干 有比劫印共两个或以上，且日干有根
     * 非旺则弱
     * @param bool $needDayun 是否加入大运计算
     * @return bool
     */
    private function is_shenwang($needDayun = true): bool
    {
        // 日干
        $rigan = $this->data['bazi'][5];
        // 地支 印数量
        $yin_num = 0;
        // 天干 比劫印数量
        $bijieyin_num = 0;
        // 日干是否有根 (如果某地支含有与某天干相同的五行，就是该天干的根)
        $is_rigan_gen = false;
        // 日干五行
        $rigan_wuxing = $this->param['wuxing'][$rigan];

        foreach ([2, 4, 6, 8] as $i)
        {
            // 本命地支本气 为日干的比劫
            if ($this->is_ygs($this->param['canggan'][$this->data['bazi'][$i]][0], $this->data['bazi'][5], '比劫'))
            {
                return true;
            }
            // 本命地支藏干
            $gans = $this->param['canggan'][$this->data['bazi'][$i]];

            $temp = $this->param['shishen'][$gans[0]][$rigan];

            if (in_array($temp, ['比肩', '劫财']))
            {
                return true;
            } elseif (in_array($temp, ['正印', '偏印']))
            {
                $yin_num++;
            }
            foreach ($gans as $gan)
            {
                if ($is_rigan_gen === false && $this->param['wuxing'][$gan] == $rigan_wuxing)
                {
                    $is_rigan_gen = true;
                }
            }
        }
        if ($needDayun === true && $this->data['dayun_now'] != null)
        {
            // 大运地支本气
            $dayun_benqi = $this->param['canggan'][$this->data['dayun_now'][1]][0];
            // 与日干的关系
            $temp = $this->param['shishen'][$dayun_benqi][$rigan];

            if (in_array($temp, ['比肩', '劫财']))
            {
                return true;
            } elseif (in_array($temp, ['正印', '偏印']))
            {
                $yin_num++;
            }
        }

        if ($is_rigan_gen === true)
        {
            if ($yin_num >= 2)
            {
                return true;
            }
            foreach ([1, 3, 7] as $j)
            {
                $temp = $this->param['shishen'][$this->data['bazi'][$j]][$rigan];
                if (in_array($temp, ['比肩', '劫财', '正印', '偏印']))
                {
                    $bijieyin_num++;
                }
            }
            if ($this->data['dayun_now'] != null)
            {
                // 大运天干
                $dayun_tiangan = $this->data['dayun_now'][0];
                // 与日干的关系
                $temp = $this->param['shishen'][$dayun_tiangan][$rigan];

                if (in_array($temp, ['比肩', '劫财', '正印', '偏印']))
                {
                    $bijieyin_num++;
                }
            }
            if ($bijieyin_num >= 2)
            {
                return true;
            }
        }
        return false;
    }

    /**
     * 流年主神
     * 流干的十神定为主神
     * 若流干为比肩
     *   流支十神定为主神
     *   流支如与命运某支合拱，合拱的十神定为主神
     */
    private function getZhuShen()
    {
        $result = [];

        $rigan = $this->data['bazi'][5];

        $liu = $this->data['liunian_now'];

        $temp = $this->param['shishen'][$liu[0]][$rigan];

        if ($temp == '比肩')
        {
            $liuzhi_benqi = $this->param['canggan'][$liu[1]][0];

            $temp = $this->param['shishen'][$liuzhi_benqi][$rigan];
            // 本命+大运 地支
            $mingyun_zhis = [
                $this->data['bazi'][2],
                $this->data['bazi'][4],
                $this->data['bazi'][6],
                $this->data['bazi'][8],
            ];
            if ($this->data['dayun_now'] != null) $mingyun_zhis[] = $this->data['dayun_now'][1];
            $zhi_shishen = [];
            foreach ($mingyun_zhis as $myz)
            {
                if ($this->is_liuhe($liu[1], $myz) || $this->is_gong($liu[1], $myz))
                {
                    $zhi_benqi = $this->param['canggan'][$myz][0];

                    $liuzhi_shishen = $this->param['shishen'][$zhi_benqi][$rigan];

                    if ($liuzhi_shishen != '比肩') $zhi_shishen[] = $liuzhi_shishen;
                }
            }

            if (!empty($zhi_shishen))
            {
                $result = $zhi_shishen;
            } else
            {
                $result[] = $temp;
            }
        } else
        {
            $result[] = $temp;
        }

        return $result;
    }

    /**
     * 干支不协
     * 流年与命运某柱干合支穿或干合支刑
     */
    private function is_ganzhibuxie()
    {
        $liu = $this->data['liunian_now'];

        $zhus = [
            [$this->data['bazi'][1], $this->data['bazi'][2]],
            [$this->data['bazi'][3], $this->data['bazi'][4]],
            [$this->data['bazi'][5], $this->data['bazi'][6]],
            [$this->data['bazi'][7], $this->data['bazi'][8]],
        ];
        if ($this->data['dayun_now'] != null)
        {
            $zhus[] = $this->data['dayun_now'];
        }
        foreach ($zhus as $zhu)
        {
            if ($this->is_wuhe($zhu[0], $liu[0]))
            {
                if ($this->is_xing($zhu[1], $liu[1]) || $this->is_liuhai($zhu[1], $liu[1]))
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 安静
     * 流支与命运支没有刑冲合穿拱
     * 刑、六冲、六合、拱、六害
     */
    private function is_anjing()
    {
        $liu = $this->data['liunian_now'];

        $zhis = [
            $this->data['bazi'][2],
            $this->data['bazi'][4],
            $this->data['bazi'][6],
            $this->data['bazi'][8],
        ];

        if ($this->data['dayun_now'] != null)
        {
            $zhis[] = $this->data['dayun_now'][1];
        }
        foreach ($zhis as $zhi)
        {
            if ($this->is_xing($zhi, $liu[1])
                || $this->is_liuchong($zhi, $liu[1])
                || $this->is_liuhe($zhi, $liu[1])
                || $this->is_gong($zhi, $liu[1])
                || $this->is_liuhai($zhi, $liu[1]))
            {
                return false;
            }
        }
        return true;
    }

    /**
     * 双冲
     * 流年与命运某柱形成天克地冲
     * 天干同性相克 偏财或七杀
     * @param array $zhu1 流年
     * @param array $zhu2 本命或大运干支 [[],[]]
     * @return bool
     */
    private function is_shuangchong($zhu1 = [], $zhu2 = [])
    {
        if (empty($zhu1) || empty($zhu2))
        {
            return false;
        }
        foreach ($zhu2 as $zhu)
        {
            if (in_array($this->param['shishen'][$zhu1[0]][$zhu[0]], ['偏财', '七杀']))
            {
                if ($this->is_liuchong($zhu[1], $zhu1[1]))
                {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 八字格局
     * @return string
     */
    public function getStructure($bazi = [])
    {
        if (empty($bazi))
        {
            $bazi = $this->data['bazi'];
        }
        /**
         * 八字格局前缀
         * 1.通变
         * 2.杂气
         */
        $str = '';
        /**
         * 八字格局
         */
        $geju = '';
        $yue_benqi = $this->param['canggan'][$bazi[4]][0];

        $temp = [];

        $canggan = $this->param['canggan'][$bazi[4]];// 月令藏干

        // 检测月令透干
        foreach ($canggan as $cg)
        {
            // 是否透出年干
            if ($this->param['wuxing'][$cg] == $this->param['wuxing'][$bazi[1]])
            {
                if (!isset($temp[$this->param['wuxing'][$bazi[1]]][$this->param['wuxing_yinyang'][$bazi[1]]]))
                    $temp[$this->param['wuxing'][$bazi[1]]][$this->param['wuxing_yinyang'][$bazi[1]]] = 0;
                $temp[$this->param['wuxing'][$bazi[1]]][$this->param['wuxing_yinyang'][$bazi[1]]]++;
                $temp[$this->param['wuxing'][$bazi[1]]]['zhi'] = $cg;
                $temp[$this->param['wuxing'][$bazi[1]]]['gan'][] = $bazi[1];
                $temp[$this->param['wuxing'][$bazi[1]]]['num'][] = 1;
            }
            // 是否透出月干
            if ($this->param['wuxing'][$cg] == $this->param['wuxing'][$bazi[3]])
            {
                if (!isset($temp[$this->param['wuxing'][$bazi[3]]][$this->param['wuxing_yinyang'][$bazi[3]]]))
                    $temp[$this->param['wuxing'][$bazi[3]]][$this->param['wuxing_yinyang'][$bazi[3]]] = 0;
                $temp[$this->param['wuxing'][$bazi[3]]][$this->param['wuxing_yinyang'][$bazi[3]]]++;
                $temp[$this->param['wuxing'][$bazi[3]]]['zhi'] = $cg;
                $temp[$this->param['wuxing'][$bazi[3]]]['gan'][] = $bazi[3];
                $temp[$this->param['wuxing'][$bazi[3]]]['num'][] = 3;
            }
            // 是否透出时干
            if ($this->param['wuxing'][$cg] == $this->param['wuxing'][$bazi[7]])
            {
                if (!isset($temp[$this->param['wuxing'][$bazi[7]]][$this->param['wuxing_yinyang'][$bazi[7]]]))
                    $temp[$this->param['wuxing'][$bazi[7]]][$this->param['wuxing_yinyang'][$bazi[7]]] = 0;
                $temp[$this->param['wuxing'][$bazi[7]]][$this->param['wuxing_yinyang'][$bazi[7]]]++;
                $temp[$this->param['wuxing'][$bazi[7]]]['zhi'] = $cg;
                $temp[$this->param['wuxing'][$bazi[7]]]['gan'][] = $bazi[7];
                $temp[$this->param['wuxing'][$bazi[7]]]['num'][] = 7;
            }
        }
        // 月令为辰戌丑未
        if (in_array($bazi[4], ['辰', '戌', '丑', '未']))
        {
            $str .= '杂气';
            // 若月令只透一种五行，且该五行非比肩劫财，则可依此确定格局；
            if (count($temp) == 1)
            {
                foreach ($temp as $w => $t)
                {
                    // 该五行非比肩劫财，则可依此确定格局；
                    if ($this->param['wuxing'][$t['zhi']] != $this->param['wuxing'][$bazi['5']])
                    {
                        $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . "格";
                    }
                    // 若月令透出一种五行但有阴阳两干，
                    if (isset($t[0]) && isset($t[1]))
                    {
                        // 正官七杀同在则取七杀格，正财偏财同现则以月令所藏为准，正印偏印同现也以月令所藏为准，食伤同现则取伤官格；
                        $_shishen = [];
                        foreach ($t['gan'] as $gan)
                        {
                            $_shishen[] = $this->param['shishen'][$gan][$bazi[5]];
                        }
                        if ($_shishen[0] == '七杀' || $_shishen[1] == '正官')
                        {
                            $geju = '七杀格';
                        } elseif ($_shishen[0] == '正财' || $_shishen[1] == '偏财')
                        {
                            $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . '格';
                        } elseif ($_shishen[0] == '正印' || $_shishen[1] == '偏印')
                        {
                            $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . '格';
                        } elseif ($_shishen[0] == '食神' || $_shishen[1] == '伤官')
                        {
                            $geju = '伤官格';
                        }
                        // 若月令只透一种五行且该五行为比肩劫财，则再观察其 所透是否为月令本气土，
                        // 若不是，则以月令本气定格，若是，则暂不取格。
                        if ($this->param['wuxing'][$t['zhi']] == $this->param['wuxing'][$bazi['5']] && $t['zhi'] != $yue_benqi)
                        {
                            $geju = $this->param['shishen'][$yue_benqi][$bazi[5]] . '格';
                        }
                    }
                    // 若月令透出五行阴阳与月令所藏不同，则以透出者为准；
                    if ((!isset($t[0]) || !isset($t[1])) && $w == $this->param['wuxing'][$t['zhi']] && $t['zhi'] != $t['gan'][0])
                    {
                        $geju = $this->param['shishen'][$t['gan'][0]][$bazi[5]] . '格';
                    }
//                    if ($geju) break;
                    if ($geju)
                    {
                        /**
                         * 由于八字格局不能有比肩或劫财，特此补充以下逻辑
                         * 如果输出结果为杂气比肩格或杂气劫财格，
                         *  增加判定：判断其月支本气是否比肩劫财，
                         *      如果不是比肩劫财，按月令本气取格+杂气，
                         *      如果是比肩劫财，取月令前一个地支的本气五行取格+杂气
                         */
                        //
                        if (in_array($geju, ['比肩格', '劫财格'], true))
                        {
                            if (in_array($this->param['shishen'][$yue_benqi][$bazi[5]], ['比肩', '劫财'], true))
                            {
                                // '辰', '戌', '丑', '未'
                                switch ($bazi[4])
                                {
                                    case '辰':
                                        $geju = $this->param['shishen']['乙'][$bazi[5]] . '格';
                                        break;
                                    case '戌':
                                        $geju = $this->param['shishen']['辛'][$bazi[5]] . '格';
                                        break;
                                    case '丑':
                                        $geju = $this->param['shishen']['癸'][$bazi[5]] . '格';
                                        break;
                                    case '未':
                                        $geju = $this->param['shishen']['丁'][$bazi[5]] . '格';
                                        break;
                                }
                            } else
                            {
                                $geju = $this->param['shishen'][$yue_benqi][$bazi[5]] . '格';
                            }
                        }
                        break;
                    }

                }
            } // 若月令透出两种或三种五行，则分别视其为何种十神再分主次，优先取官杀、其次为财、再次为印星，最次为食伤；
            elseif (count($temp) > 1)
            {
                $tougan_shishen = [];
                foreach ($temp as $w => $t)
                {
                    // 遍历所透天干
                    foreach ($t['gan'] as $t_gan)
                    {

                        $ts_shishen = $this->param['shishen'][$t_gan][$bazi[5]];// 此处为所透天干，不是藏干

                        if (in_array($ts_shishen, ['正官', '七杀', '正财', '偏财', '正印', '偏印', '食神', '伤官']))
                        {
                            $tougan_shishen[] = $ts_shishen;
                        }
                    }
                }

                // 正官七杀同在则取七杀格，正财偏财同现则以月令所藏为准，正印偏印同现也以月令所藏为准，食伤同现则取伤官格；
                if (in_array('七杀', $tougan_shishen)) $geju = '七杀格';
                elseif (in_array('正官', $tougan_shishen)) $geju = '正官格';
                elseif (in_array('正财', $tougan_shishen) && in_array('偏财', $tougan_shishen))
                {
                    foreach ($canggan as $cg)
                    {
                        if ($this->param['shishen'][$cg][$bazi[5]] == '正财') $geju = '正财格';
                        if ($this->param['shishen'][$cg][$bazi[5]] == '偏财') $geju = '偏财格';
                    }
                } elseif (in_array('正财', $tougan_shishen)) $geju = '正财格';
                elseif (in_array('偏财', $tougan_shishen)) $geju = '偏财格';
                elseif (in_array('正印', $tougan_shishen) && in_array('偏印', $tougan_shishen))
                {
                    foreach ($canggan as $cg)
                    {
                        if ($this->param['shishen'][$cg][$bazi[5]] == '正印') $geju = '正印格';
                        if ($this->param['shishen'][$cg][$bazi[5]] == '偏印') $geju = '偏印格';
                    }
                } elseif (in_array('正印', $tougan_shishen)) $geju = '正印格';
                elseif (in_array('偏印', $tougan_shishen)) $geju = '偏印格';
                elseif (in_array('伤官', $tougan_shishen)) $geju = '伤官格';
                elseif (in_array('食神', $tougan_shishen)) $geju = '食神格';

            }

        } // 月令非辰戌丑未
        else
        {
            $yue_shishen = $this->param['shishen'][$yue_benqi][$this->data['bazi'][5]];
            if ($yue_shishen == '比肩')
            {
                $geju = '建禄格';
            } elseif ($yue_shishen == '劫财')
            {
                if (in_array($this->data['bazi'][5], ['甲', '丙', '戊', '庚', '壬'])) $geju = '月刃格';

                else $geju = '月劫格';

            }

            if ($geju == '')
            {
                // 看月令本气五行是否透出。
                // 若不透则以月令所藏本气取格；

                // 若只透阴干或只透阳干则以所透之物取格。
                if (isset($temp[$this->param['wuxing'][$yue_benqi]]))
                {
                    if (
                        (isset($temp[$this->param['wuxing'][$yue_benqi]][0])
                            && !isset($temp[$this->param['wuxing'][$yue_benqi]][1]))
                        || (isset($temp[$this->param['wuxing'][$yue_benqi]][1])
                            && !isset($temp[$this->param['wuxing'][$yue_benqi]][0]))
                    )
                    {
                        $geju = $this->param['shishen'][$temp[$this->param['wuxing'][$yue_benqi]]['gan'][0]][$bazi[5]] . '格';
                    }
                } else
                {
                    $geju = $this->param['shishen'][$yue_benqi][$bazi[5]] . '格';
                }
                foreach ($temp as $w => $t)
                {
                    // 若透阴阳两干则参照第二步中蓝字部分；
                    if (isset($t[0]) && isset($t[1]) && count($temp) == 1)
                    {
                        // 正官七杀同在则取七杀格，正财偏财同现则以月令所藏为准，
                        // 正印偏印同现也以月令所藏为准，食伤同现则取伤官格；
                        $_shishen = [];
                        foreach ($t['gan'] as $gan)
                        {
                            $_shishen[] = $this->param['shishen'][$gan][$bazi[5]];
                        }
                        if (in_array('七杀', $_shishen) && in_array('正官', $_shishen))
                        {
                            $geju = '七杀格';
                        } elseif (in_array('正财', $_shishen) || in_array('偏财', $_shishen))
                        {
                            // 同在以月令所藏为准
                            if (in_array('正财', $_shishen) && in_array('偏财', $_shishen))
                            {
                                foreach ($canggan as $cg)
                                {
                                    if ($this->param['shishen'][$cg][$bazi[5]] == '正财') $geju = '正财格';
                                    if ($this->param['shishen'][$cg][$bazi[5]] == '偏财') $geju = '偏财格';
                                }
                            } else
                            {
                                $geju = $this->param['shishen'][0] . '格';
                            }
                        } elseif (in_array('正印', $_shishen) && in_array('偏印', $_shishen))
                        {
                            $geju = $this->param['shishen'][$t['zhi']][$bazi[5]] . '格';
                        } elseif (in_array('食神', $_shishen) && in_array('伤官', $_shishen))
                        {
                            $geju = '伤官格';
                        }

                    }
                    if ($geju) break;
                }
            }
        }
        // 戊己日主生在辰戌丑未月份
        if ($geju === '')
        {
            // 若月支为辰
            if ($bazi[4] == '辰')
            {
                // 它支有申或子或亥，以癸水定格，前面加“通变”二字
                if (
                    in_array($bazi[2], ['申', '子', '亥'])
                    || in_array($bazi[6], ['申', '子', '亥'])
                    || in_array($bazi[8], ['申', '子', '亥'])
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['癸'][$bazi[5]] . '格';
                } // 它支同时有寅卯二字，则“七杀格”，加通变二字
                elseif (
                    ($bazi[2] == '寅' && ($bazi[6] == '卯' || $bazi[8] == '卯'))
                    || ($bazi[2] == '卯' && ($bazi[6] == '寅' || $bazi[8] == '寅'))
                    || ($bazi[6] == '寅' && ($bazi[2] == '卯' || $bazi[8] == '卯'))
                    || ($bazi[6] == '卯' && ($bazi[2] == '寅' || $bazi[8] == '寅'))
                    || ($bazi[8] == '寅' && ($bazi[2] == '卯' || $bazi[6] == '卯'))
                    || ($bazi[8] == '卯' && ($bazi[2] == '寅' || $bazi[6] == '寅'))
                )
                {
                    $str = '通变';
                    $geju = '七杀格';
                }
            } // 若月支为戌
            elseif ($bazi[4] == '戌')
            {
                // 它支有寅或午或巳，则以丁火定格，加通变二字
                if (
                    in_array($bazi[2], ['寅', '午', '巳'])
                    || in_array($bazi[6], ['寅', '午', '巳'])
                    || in_array($bazi[8], ['寅', '午', '巳'])
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['丁'][$bazi[5]] . '格';
                } // 它支同时有申酉二字，则“伤官格”，加通变二字
                elseif (
                    ($bazi[2] == '申' && ($bazi[6] == '酉' || $bazi[8] == '酉'))
                    || ($bazi[2] == '酉' && ($bazi[6] == '申' || $bazi[8] == '申'))
                    || ($bazi[6] == '申' && ($bazi[2] == '酉' || $bazi[8] == '酉'))
                    || ($bazi[6] == '酉' && ($bazi[2] == '申' || $bazi[8] == '申'))
                    || ($bazi[8] == '申' && ($bazi[2] == '酉' || $bazi[6] == '酉'))
                    || ($bazi[8] == '酉' && ($bazi[2] == '申' || $bazi[6] == '申'))
                )
                {
                    $str = '通变';
                    $geju = '伤官格';
                }
            } // 若月支为丑
            elseif ($bazi[4] == '丑')
            {
                // 它支有巳或酉或申，则“伤官格”，加通变二字
                if (
                    in_array($bazi[2], ['酉', '申', '巳'])
                    || in_array($bazi[6], ['酉', '申', '巳'])
                    || in_array($bazi[8], ['酉', '申', '巳'])
                )
                {
                    $str = '通变';
                    $geju = '伤官格';
                } // 它支同时有亥子二字，则以癸水定格，加通变二字
                elseif (
                    ($bazi[2] == '亥' && ($bazi[6] == '子' || $bazi[8] == '子'))
                    || ($bazi[2] == '子' && ($bazi[6] == '亥' || $bazi[8] == '亥'))
                    || ($bazi[6] == '亥' && ($bazi[2] == '子' || $bazi[8] == '子'))
                    || ($bazi[6] == '子' && ($bazi[2] == '亥' || $bazi[8] == '亥'))
                    || ($bazi[8] == '亥' && ($bazi[2] == '子' || $bazi[6] == '子'))
                    || ($bazi[8] == '子' && ($bazi[2] == '亥' || $bazi[6] == '亥'))
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['癸'][$bazi[5]] . '格';
                }
            } // 若月支为未
            elseif ($bazi[4] == '未')
            {
                // 它支有亥或卯或寅，则“七杀格”，加通变二字
                if (
                    in_array($bazi[2], ['亥', '卯', '寅'])
                    || in_array($bazi[6], ['亥', '卯', '寅'])
                    || in_array($bazi[8], ['亥', '卯', '寅'])
                )
                {
                    $str = '通变';
                    $geju = '七杀格';
                } // 它支同时有巳午二字，则以丁火定格，加通变二字
                elseif (
                    ($bazi[2] == '巳' && ($bazi[6] == '午' || $bazi[8] == '午'))
                    || ($bazi[2] == '午' && ($bazi[6] == '巳' || $bazi[8] == '巳'))
                    || ($bazi[6] == '巳' && ($bazi[2] == '午' || $bazi[8] == '午'))
                    || ($bazi[6] == '午' && ($bazi[2] == '巳' || $bazi[8] == '巳'))
                    || ($bazi[8] == '巳' && ($bazi[2] == '午' || $bazi[6] == '午'))
                    || ($bazi[8] == '午' && ($bazi[2] == '巳' || $bazi[6] == '巳'))
                )
                {
                    $str = '通变';
                    $geju = $this->param['shishen']['丁'][$bazi[5]] . '格';
                }
            }
        }
        // 以上皆非则“无主格”
        if ($geju === '')
        {
            $geju = '无主格';
        }
        /**
         * 八字格局分格
         */
        $fenge = '';
        // 检测格局成败及用神划分，定分格
        if ($geju == '正官格')
        {

        } elseif ($geju == '正财格' || $geju == '偏财格')
        {

        } elseif ($geju == '七杀格')
        {

        } elseif ($geju == '正印格' || $geju == '偏印格')
        {

        } elseif ($str == '杂气' && $geju == '食神格')
        {

        } elseif ($geju == '伤官格')
        {

        } elseif ($geju == '建禄格')
        {

        } elseif ($geju == '月劫格')
        {

        } elseif ($geju == '月刃格')
        {

        }
        if ($geju == '无主格') $str = '';

        return $str . $geju . $fenge;
    }

    /**
     * 获取十神关系表
     * @return mixed
     */
    public function getShishenParam()
    {
        return $this->param['shishen'];
    }

    /**
     * 计算五行旺度
     * @return int[] 0=>木,1=>火,2=>土,3=>金,4=>水
     */
    public function getWuxingWang(): array
    {
        $data = $this->getUserData();
        $bazi = $data['bazi'];// 八字下标为1～8 奇数为天干  偶数为地支
//        echo '<td>' . implode('', $bazi) . '</td>';
        $canggan = $data['canggan'];// 藏干下标为 0~3 对应年、月、日、时
        /**
         * 天干属性表
         *  yy：阴阳系数 阳1   阴0.75
         *  wx: 五行属性 0=>木,1=>火,2=>土,3=>金,4=>水
         *  sx: 实象值
         *  xx：虚像值
         */
        $tianganList = [
            '甲' => ['yy' => 1, 'wx' => 0, 'sx' => 0, 'xx' => 0], '乙' => ['yy' => 0.7, 'wx' => 0, 'sx' => 0, 'xx' => 0],
            '丙' => ['yy' => 1, 'wx' => 1, 'sx' => 0, 'xx' => 0], '丁' => ['yy' => 0.7, 'wx' => 1, 'sx' => 0, 'xx' => 0],
            '戊' => ['yy' => 1, 'wx' => 2, 'sx' => 0, 'xx' => 0], '己' => ['yy' => 0.7, 'wx' => 2, 'sx' => 0, 'xx' => 0],
            '庚' => ['yy' => 1, 'wx' => 3, 'sx' => 0, 'xx' => 0], '辛' => ['yy' => 0.7, 'wx' => 3, 'sx' => 0, 'xx' => 0],
            '壬' => ['yy' => 1, 'wx' => 4, 'sx' => 0, 'xx' => 0], '癸' => ['yy' => 0.7, 'wx' => 4, 'sx' => 0, 'xx' => 0],
        ];
        // 找出所有的地支藏干 （地支藏干数组 合并后去重）
        $dizhiCangganList = array_unique(array_merge($canggan[0], $canggan[1], $canggan[2], $canggan[3]));
        // 未在地支中出现的天干
        $tianganNotInDizhi = array_diff(['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'], $dizhiCangganList);
        // 虚象值计算
        if (!empty($tianganNotInDizhi))
        {
            foreach ($tianganNotInDizhi as $tg)
            {
                if ($tg === $bazi[1])
                {
                    // 每出现一次+（0.5*阴阳系数）
                    $tianganList[$tg]['xx'] += 0.5 * $tianganList[$tg]['yy'];
                }
                if ($tg === $bazi[3])
                {
                    // 每出现一次+（0.5*阴阳系数）
                    $tianganList[$tg]['xx'] += 0.5 * $tianganList[$tg]['yy'];
                }
                if ($tg === $bazi[5])
                {
                    // 每出现一次+（0.5*阴阳系数）
                    $tianganList[$tg]['xx'] += 0.5 * $tianganList[$tg]['yy'];
                }
                if ($tg === $bazi[7])
                {
                    // 每出现一次+（0.5*阴阳系数）
                    $tianganList[$tg]['xx'] += 0.5 * $tianganList[$tg]['yy'];
                }
            }
        }
        // 实象值计算
        foreach ($dizhiCangganList as $cg)
        {
            $diqiScore = 0;
            // 年柱 位置系数：0.5
            if (in_array($cg, $canggan[0], true))
            {
                // 本藏系数 本气1，藏气0.3
                $bc = $cg === $canggan[0][0] ? 1 : 0.4;
                // 位置*阴阳*本藏
                $diqiScore += 0.5 * $tianganList[$cg]['yy'] * $bc;
            }
            // 月柱 位置系数：1
            if (in_array($cg, $canggan[1], true))
            {
                // 本藏系数 本气1，藏气0.3
                $bc = $cg === $canggan[1][0] ? 1 : 0.4;
                // 位置*阴阳*本藏
                $diqiScore += $tianganList[$cg]['yy'] * $bc;
            }
            // 日柱 位置系数：0.8
            if (in_array($cg, $canggan[2], true))
            {
                // 本藏系数 本气1，藏气0.3
                $bc = $cg === $canggan[2][0] ? 1 : 0.4;
                // 位置*阴阳*本藏
                $diqiScore += 0.8 * $tianganList[$cg]['yy'] * $bc;
            }
            // 时柱 位置系数：0.5
            if (in_array($cg, $canggan[3], true))
            {
                // 本藏系数 本气1，藏气0.3
                $bc = $cg === $canggan[3][0] ? 1 : 0.4;
                // 位置*阴阳*本藏
                $diqiScore += 0.5 * $tianganList[$cg]['yy'] * $bc;
            }
            //		透干系数（如该地支藏干透到天干上）
            //			月干1.5，日干1.5，时干1.4，年干1.3
            //			多次透干，以透干值最高分数*1.2（多透一次则乘1次）
            $tg = 1;
            $tgNum = 0;

            if ($cg === $bazi[3])
            {
                $tg = $tg < 1.5 ? 1.5 : $tg;
                $tgNum++;
            }
            if ($cg === $bazi[5])
            {
                $tg = $tg < 1.5 ? 1.5 : $tg;
                $tgNum++;
            }
            if ($cg === $bazi[7])
            {
                $tg = $tg < 1.4 ? 1.4 : $tg;
                $tgNum++;
            }
            if ($cg === $bazi[1])
            {
                $tg = $tg < 1.3 ? 1.3 : $tg;
                $tgNum++;
            }
            // 地气值*透干系数=该干实象值
            $tianganList[$cg]['sx'] = $diqiScore * $tg * (1.2 ** $tgNum);
        }
        // 五行旺度计算 0=>木,1=>火,2=>土,3=>金,4=>水
        $wxw = [0, 0, 0, 0, 0];
        if ($tianganList['甲']['sx'] > 0 || $tianganList['乙']['sx'] > 0)
        {
            $wxw[0] = $tianganList['甲']['sx'] + $tianganList['乙']['sx'] + ($tianganList['甲']['xx'] + $tianganList['乙']['xx']) * 1.5;
        } else
        {
            $wxw[0] = ($tianganList['甲']['xx'] + $tianganList['乙']['xx']) / 3;
        }
        if ($tianganList['丙']['sx'] > 0 || $tianganList['丁']['sx'] > 0)
        {
            $wxw[1] = $tianganList['丙']['sx'] + $tianganList['丁']['sx'] + ($tianganList['丙']['xx'] + $tianganList['丁']['xx']) * 1.5;
        } else
        {
            $wxw[1] = ($tianganList['丙']['xx'] + $tianganList['丁']['xx']) / 3;
        }
        if ($tianganList['戊']['sx'] > 0 || $tianganList['己']['sx'] > 0)
        {
            $wxw[2] = $tianganList['戊']['sx'] + $tianganList['己']['sx'] + ($tianganList['戊']['xx'] + $tianganList['己']['xx']) * 1.5;
        } else
        {
            $wxw[2] = ($tianganList['戊']['xx'] + $tianganList['己']['xx']) / 3;
        }
        if ($tianganList['庚']['sx'] > 0 || $tianganList['辛']['sx'] > 0)
        {
            $wxw[3] = $tianganList['庚']['sx'] + $tianganList['辛']['sx'] + ($tianganList['庚']['xx'] + $tianganList['辛']['xx']) * 1.5;
        } else
        {
            $wxw[3] = ($tianganList['庚']['xx'] + $tianganList['辛']['xx']) / 3;
        }
        if ($tianganList['壬']['sx'] > 0 || $tianganList['癸']['sx'] > 0)
        {
            $wxw[4] = $tianganList['壬']['sx'] + $tianganList['癸']['sx'] + ($tianganList['壬']['xx'] + $tianganList['癸']['xx']) * 1.5;
        } else
        {
            $wxw[4] = ($tianganList['壬']['xx'] + $tianganList['癸']['xx']) / 3;
        }
        return $wxw;
    }

    /**
     * 计算亲密度
     * @param $x string 八字里的某五行/十神/天干亲密度
     * @return array 相对亲密度和绝对亲密度
     */
    protected function getIntimacy($x)
    {
        $rela = 0;
        $abso = 0;
        //  五行
        if (in_array($x, ['木', '火', '土', '金', '水'], true))
        {

        } //  天干
        elseif (in_array($x, ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'], true))
        {

        } // 十神
        elseif (in_array($x, [
            '比肩', '劫财', '偏印', '正印', '七杀', '正官', '偏财', '正财', '食神', '伤官',
            '比', '劫', '枭', '印', '杀', '官', '财', '才', '食', '伤',
        ], true))
        {

        }

        /**
         * x出现位置
         *    日支10，月干时干8，时支6，月支4，年干支1
         *    如有明现（天干或地支本气）则不计算藏气，无明现则计算藏气并令数值折半，如藏气仅出现一次则数值不折半，建议
         */


        // 轮子：亲密度
        //	x出现位置
        //		日支10，月干时干8，时支6，月支4，年干年支1
        //		如有明现（天干或地支本气）则不计算藏气，无明现则计算藏气并令数值折半，如藏气仅出现一次则数值不折半
        //			建议轮子：明现
        //		多次出现则叠加
        //	向心力
        //		x在天干
        //			坐支与日支相拱或相合+5
        //			与日干坐支相同+3
        //		x在地支
        //			与日支相拱或相合+7
        //		如该支为年支，且本气被月支本气所克，则得分折半
        //	离心力
        //		x在天干
        //			坐支与日支相害或相冲+5
        //		x在地支
        //			与日支相害或相冲+7
        //		存在x受克的结构
        //			月日时每有一个克x的天干或地支（本气）+3
        //	相对亲密度
        //		x所有位置分+所有向心力分
        //	绝对亲密度
        //		相对亲密度-离心力分

        return ['rela' => $rela, 'abso' => $abso];
    }

    /**
     * 计算受克分
     * @return number 返回受克分数
     */
    protected function shouKeScore()
    {
        $score = 0;

        /**
         * A五行克B五行，出现A五行与B五行同柱或相邻的情况则任务A克B（只计算本气）
         * 天干
         *  同性克或阳克阴计克力为10
         *  阴克阳记克力为5
         * 地支
         *  两者有冲穿刑破关系记克力为10（阴克阳折半）
         *  两者有拱合关系记克力为5（阴克阳折半）
         *  无关系记克力为3（阴克阳折半）
         * 同柱
         *  干克支：记克力10，阴克阳折半
         *  支克干：记克力6，阴克阳折半
         * 例外：
         *    AB都在天干但隔位
         *      如受克者先出现则克力3（阴克阳折半）
         *      如受克者后出现则克力2（阴克阳折半）
         *    AB都在地支但隔位
         *      两者有冲穿刑破关系 3（阴克阳折半）
         * 每有一组组合则记为一次受克，所有受克分相加（大于等于5被认为拥有B受克结构）
         */

        // 轮子：受克结构
        //	A五行克B五行，出现A五行与B五行同柱或相邻的情况则认为A克B（只计算本气）
        //	同性克或阳克阴计克力为10
        //	阴克阳记克力为5
        //	两者有冲穿刑破关系记克力为10（阴克阳折半）
        //	两者有拱合关系记克力为5（阴克阳折半）
        //	无关系记克力为3（阴克阳折半）
        //	干克支：记克力10，阴克阳折半
        //	支克干：记克力6，阴克阳折半
        //	例外
        //		AB都在天干但隔位
        //			如受克者先出现则克力3
        //			如受克者后出现则克力2
        //		AB都在地支但隔位
        //			两者有冲穿刑破关系
        //				3
        //		遵守阴克阳减半原则
        //	每有一组组合则记为一次受克，所有受克分相加（大于等于5被认为拥有B受克结构）
        //	输出B受克分，输出B是否有受克结构
        //	天干
        //	地支
        //	同柱


        return $score;
    }

    /**
     * 计算控制度
     * @param $x string 木、火、土、金、水、比肩、劫财、正印、偏印、正财、偏财、食神、伤官、正官、偏官、比劫、枭印、食伤、财星、官杀
     * 明现：透干或有本气为明现
     * 库：['辰' => '癸', '戌' => '丁', '丑' => '辛', '未' => '乙']  只有这四种
     * 财星：正财偏财
     */
    protected function controlDegree($x)
    {
        //轮子：控制度
        //	反映一个五行或十神对日主的压制、控制
        //	看该五行（或十神）是否明现或在库
        //		透干或有本气为明现，有库在为在库
        //		贴/隔/遥系数=1/0.8/0.6
        //		如明现，看其是否对日主形成控制结构
        //			1、明现在干，其克日干（是官+5，杀+10）
        //				此时如坐支同日支，取值*2
        //				此时如坐支刑/冲/害日支，取值+3/10/3
        //			2、明现在干，其坐支与日支刑冲合害，同时坐支本库气克日支本库气，+4/5（异性/同性）
        //			3、明现在干，其坐支本气为官杀，+2/4
        //				此时其坐支与日禄刑冲合害+3/6
        //				此时其坐支与日支刑冲合害+2/4
        //				同时满足依次相加
        //			4、明现在干，其坐支与日禄刑冲合害，同时坐支本气库其克日禄本气，+5/9
        //			5、明现在支，其与日支刑冲合害，且与日支相克+5/10
        //			6、明现在支，本气为官杀，+3/6
        //				与日支刑冲合害+3/6
        //				与日禄刑冲合害+3/6
        //			7、明现在支，其干为官杀，+2/4
        //				与日支刑冲合害+2/4
        //				与日禄刑冲合害+2/4
        //		所有明现干支都取值一遍，并乘以系数

        // 当前参数为一个五行
        if (in_array($x, ['木', '火', '土', '金', '水'], true))
        {
            if ($this->param['wuxing'][$x])
            {

            }
        }
    }

    protected function getbaziData()
    {
        /**
         * [
         *    [
         *      'name' => '甲', // 天干地支  天干：甲乙丙丁戊己庚辛壬癸 地支：子丑寅卯辰巳午未申酉戌亥
         *      'position' => 1, // 奇数为天干 偶数为地支 1=>年干,2=>年支,3=>月干,4=>月支,5=>日干,6=>日支,7=>时干,8=>时支
         *      'wuxing' => '木', // 五行属性 木火土金水
         *      'yinyang' => 1, // 阴阳属性 0=>阴,1=>阳
         *      'shishen' => '食', // 十神简写
         *      'shishen_whole' => '食神', // 十神全称
         *      'cangan' => [], // 地支藏干
         *      'benqi' => '', // 地支藏干本气
         *    ]
         * ]
         */
        // 乙亥 己卯 甲子 乙丑
        $data = [
            [
                'name' => '乙', // 天干地支  天干：甲乙丙丁戊己庚辛壬癸 地支：子丑寅卯辰巳午未申酉戌亥
                'position' => 1, // 奇数为天干 偶数为地支 1=>年干,2=>年支,3=>月干,4=>月支,5=>日干,6=>日支,7=>时干,8=>时支
                'wuxing' => '木', // 五行属性 木火土金水
                'yinyang' => 0, // 阴阳属性 0=>阴,1=>阳
                'shishen' => '劫', // 十神简写
                'shishen_whole' => '劫财', // 十神全称
                'cangan' => [], // 地支藏干
                'benqi' => '', // 地支藏干本气
            ],
            [
                'name' => '亥', // 天干地支  天干：甲乙丙丁戊己庚辛壬癸 地支：子丑寅卯辰巳午未申酉戌亥
                'position' => 2, // 奇数为天干 偶数为地支 1=>年干,2=>年支,3=>月干,4=>月支,5=>日干,6=>日支,7=>时干,8=>时支
                'wuxing' => '水', // 五行属性 木火土金水
                'yinyang' => 1, // 阴阳属性 0=>阴,1=>阳
                'shishen' => '', // 十神简写
                'shishen_whole' => '', // 十神全称
                'cangan' => [
                    [
                        'name' => '壬',
                        'wuxing' => '水',
                        'yinyang' => 1,
                        'shishen' => '枭',
                        'shishen_whole' => '枭印',
                    ],
                ], // 地支藏干
                'benqi' => '', // 地支藏干本气
            ],
            [
                'name' => '己',
                'position' => 3,
                'wuxing' => '木',
                'yinyang' => 1,
                'shishen' => '食',
                'shishen_whole' => '食神',
                'cangan' => [],
                'benqi' => '',
            ],
            [
                'name' => '酉',
                'position' => 4,
                'wuxing' => '木',
                'yinyang' => 1,
                'shishen' => '食',
                'shishen_whole' => '食神',
                'cangan' => [],
                'benqi' => '',
            ],

        ];
    }

    /**
     * 计算用户八字外格
     * @param array $bazi
     * @return array
     */
    public function baziwaige($bazi = []): array
    {
        $res = [];
        // 八字中的所有天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 八字中的所有地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        // 计算地支中每个字出现的次数
        $baziRepeatCount = array_count_values($bazi);
        $shishen = $this->param['shishen'];
        $canggan = $this->param['canggan'];
        $shensha = $this->param['shensha'];
        // 日干
        $rigan = $tiangan[2];
        // 日柱
        $rizhu = $bazi[5] . $bazi[6];
        // 处理天干十神
        $tianganShishen = [];
        foreach ($tiangan as $k1 => $v1)
        {
            if ($k1 === 2) continue;
            $tianganShishen[$k1] = $shishen[$v1][$rigan];
        }
        // 处理地支藏干的十神
        $dizhiShishen = [];
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                $dizhiShishen[] = [
                    'zhi' => $v1,
                    'zhi_weizhi' => $k1,
                    'canggan' => $v2,
                    'canggan_weizhi' => $k2,
                    'shishen' => $shishen[$v2][$rigan],
                ];
            }
        }
        // 地支中是否有两个及以上的辰
        $lianggeChen = isset($baziRepeatCount['辰']) && $baziRepeatCount['辰'] >= 2;
        /**
         * 壬骑龙背
         *  日柱壬辰，其它柱有寅或卯或辰，或日柱壬寅，有两位以上辰
         */
        if (($rizhu === '壬辰'
                && (in_array($bazi[2], ['寅', '卯', '辰'], true)
                    || in_array($bazi[4], ['寅', '卯', '辰'], true)
                    || in_array($bazi[8], ['寅', '卯', '辰'], true)))
            || ($rizhu === '壬寅' && $lianggeChen))
        {
            $res[] = 0;
        }
        /**
         * 壬骑龙背（标准）
         *  日柱壬辰或壬寅，八字中共两位以上的辰和一位以上的寅，不见戌，月令不见丑未，天干不见己
         */
        if (in_array($rizhu, ['壬辰', '壬寅'], true)
            && $lianggeChen && isset($baziRepeatCount['寅'])
            && !isset($baziRepeatCount['戌']) && !in_array($dizhi[2], ['丑', '未'], true)
            && !in_array('己', $tiangan, true))
        {
            $res[] = 1;
        }
        /**
         * 时上偏财
         *  时干为偏财或时支本气偏财，且年月日不见偏财
         */
        if ($shishen[$tiangan[3]][$rigan] === '偏财'
            || $shishen[$canggan[$dizhi[3]][0]][$rigan] === '偏财')
        {
            $isJianPiancai = false;
            foreach ($tianganShishen as $k1 => $v1)
            {
                if ($k1 <= 1 && $v1 === '偏财')
                {
                    $isJianPiancai = true;
                    break;
                }
            }
            if (!$isJianPiancai)
            {
                foreach ($dizhiShishen as $v1)
                {
                    // 查看支本气十神
                    if ($v1['zhi_weizhi'] <= 2 && $v1['canggan_weizhi'] === 0 && $v1['shishen'] === '偏财')
                    {
                        $isJianPiancai = true;
                        break;
                    }
                }
            }
            if (!$isJianPiancai)
            {
                $res[] = 2;
            }
        }
        /**
         * 时上一位贵
         *  时干为七杀或时支本气为七杀，且年月日不见七杀，且年月日有食神或伤官或比劫或羊刃或正印（地支只看本气）
         */
        if ($shishen[$tiangan[3]][$rigan] === '七杀'
            || $shishen[$canggan[$dizhi[3]][0]][$rigan] === '七杀')
        {
            $isJianQisha = false;
            $isJianSSBJZY = false;
            foreach ($tianganShishen as $k1 => $v1)
            {
                if ($k1 <= 1)
                {
                    if ($v1 === '七杀')
                    {
                        $isJianQisha = true;
                    }

                    if (in_array($v1, ['食神', '伤官', '比肩', '劫财', '正印'], true))
                    {
                        $isJianSSBJZY = true;
                    }
                }
            }
            if (!$isJianQisha)
            {
                foreach ($dizhiShishen as $v1)
                {
                    if ($v1['zhi_weizhi'] <= 2 && $v1['canggan_weizhi'] === 0 && $v1['shishen'] === '七杀')
                    {
                        $isJianQisha = true;
                    }
                    if ($shensha['羊刃'][$rigan] === $v1['zhi'] || ($v1['canggan_weizhi'] === 0 && in_array($v1['shishen'], ['食神', '伤官', '比肩', '劫财', '正印'], true)))
                    {
                        $isJianSSBJZY = true;
                    }
                }
            }
            if (!$isJianQisha && $isJianSSBJZY)
            {
                $res[] = 3;
            }
        }
        /**
         * 归禄格
         *  时支是日干的禄神（但不包括乙、丙、辛日），四柱没有官杀
         */
        if (!in_array($rigan, ['乙', '丙', '辛'], true) && $shensha['禄神'][$rigan] === $dizhi[3])
        {
            $isJianGuansha = false;
            foreach ($tianganShishen as $v1)
            {
                if ($v1 === '正官' || $v1 === '七杀')
                {
                    $isJianGuansha = true;
                    break;
                }
            }
            if (!$isJianGuansha)
            {
                foreach ($dizhiShishen as $v1)
                {
                    if ($v1['canggan_weizhi'] === 0 && ($v1['shishen'] === '正官' || $v1['shishen'] === '七杀'))
                    {
                        $isJianGuansha = true;
                        break;
                    }
                }
            }
            if (!$isJianGuansha)
            {
                $res[] = 4;
            }
        }
        /**
         * 刑合格
         *  癸亥、癸酉或癸卯日，寅时，没有戊己申巳
         */
        if ($dizhi[3] === '寅' && in_array($rizhu, ['癸亥', '癸酉', '癸卯'], true)
            && !array_intersect(['戊', '己'], $tiangan) && !array_intersect(['申', '巳'], $dizhi))
        {
            $res[] = 5;
        }
        /**
         * 合禄格
         *  戊日庚申时，八字不见甲乙寅卯；或癸日庚申时，八字不见戊
         */
        if (in_array($dizhi[3], ['庚', '申'], true)
            && (($rigan === '戊' && !array_intersect(['甲', '乙'], $tiangan) && !array_intersect(['寅', '卯'], $dizhi))
                || ($rigan === '癸' && !in_array('戊', $tiangan, true))))
        {
            $res[] = 6;
        }
        /**
         * 飞天禄马
         *   1、庚子或壬子日，且地支有两个子或以上，无丁、己、丑、午字，有寅、戌、未之一；
         *   2、辛亥或癸亥日，地支有两个亥或以上，无巳、戊、丙、寅字，有申、酉、丑之一
         */
        if ((in_array($rizhu, ['庚子', '壬子'], true) && isset($baziRepeatCount['子']) && $baziRepeatCount['子'] >= 2 && !array_intersect(['丁', '己'], $tiangan) && !array_intersect(['丑', '午'], $dizhi) && array_intersect(['寅', '戌', '未'], $dizhi))
            || (in_array($rizhu, ['辛亥', '癸亥'], true) && isset($baziRepeatCount['亥']) && $baziRepeatCount['亥'] >= 2 && !array_intersect(['丙', '戊'], $tiangan) && !array_intersect(['寅', '巳'], $dizhi) && array_intersect(['申', '酉', '丑'], $dizhi)))
        {
            $res[] = 7;
        }
        /**
         * 倒冲禄马
         *  1、丁巳日，八字巳有两个或以上，无壬、亥，无申
         *  2、丙午日，八字午有两个或以上，无癸、子，无未
         */
        if (($rizhu === '丁巳' && isset($baziRepeatCount['巳']) && $baziRepeatCount['巳'] >= 2 & !isset($baziRepeatCount['壬'], $baziRepeatCount['亥'], $baziRepeatCount['申']))
            || ($rizhu === '丙午' && isset($baziRepeatCount['午']) && $baziRepeatCount['午'] >= 2 & !isset($baziRepeatCount['癸'], $baziRepeatCount['子'], $baziRepeatCount['未'])))
        {
            $res[] = 8;
        }
        /**
         * 六乙鼠贵
         *  日干为乙，时支是子，八字无庚无申
         */
        if ($rigan === '乙' && $dizhi[3] === '子' && !in_array('庚', $tiangan, true) && !in_array('申', $dizhi, true))
        {
            $res[] = 9;
        }
        /**
         * 六阴朝阳
         *  辛日主，时支为子，四柱无丙、巳、午
         */
        if ($rizhu === '辛子' && !in_array('丙', $tiangan, true) && !isset($baziRepeatCount['巳'], $baziRepeatCount['午']))
        {
            $res[] = 10;
        }
        /**
         * 井栏叉格
         *  日柱为庚申、庚子或庚辰，地支申子辰各至少一个，八字无寅午戌丙丁巳等字
         */
        if (in_array($rizhu, ['庚申', '庚子', '庚辰'], true)
            && isset($baziRepeatCount['申'], $baziRepeatCount['子'], $baziRepeatCount['辰'])
            && !in_array('丙', $tiangan, true) && !in_array('丁', $tiangan, true)
            && !isset($baziRepeatCount['寅'], $baziRepeatCount['午'], $baziRepeatCount['戌'], $baziRepeatCount['巳']))
        {
            $res[] = 11;
        }
        /**
         * 子遥巳禄
         *  日柱甲子，时柱甲子，八字无庚辛申酉丑午
         */
        if ($rizhu === '甲子' && $tiangan[3] === '甲' && $dizhi[3] === '子' && !in_array('庚', $tiangan, true) && !in_array('辛', $tiangan, true) && !isset($baziRepeatCount['申'], $baziRepeatCount['酉'], $baziRepeatCount['丑'], $baziRepeatCount['午']))
        {
            $res[] = 12;
        }
        /**
         * 丑遥巳禄
         *  日柱辛丑或癸丑，且四地支不止一个丑，无子、巳
         */
        if (in_array($rizhu, ['辛丑', '癸丑'], true) && isset($baziRepeatCount['丑']) && $baziRepeatCount['丑'] && !isset($baziRepeatCount['子'], $baziRepeatCount['巳']))
        {
            $res[] = 13;
        }
        /**
         * 金神格
         *  日干为甲或己，时支巳、酉或丑
         */
        if (in_array($rigan, ['甲', '己'], true) && in_array($dizhi[2], ['巳', '酉', '丑'], true))
        {
            $res[] = 14;
        }
        /**
         * 魁罡格
         *  日柱为庚戌、庚辰、壬辰、戊戌，四支不同时出现辰戌
         */
        if (in_array($rizhu, ['庚戌', '庚辰', '壬辰', '戊戌'], true) && !isset($baziRepeatCount['辰'], $baziRepeatCount['戌']))
        {
            $res[] = 15;
        }
        /**
         * 日贵格
         *  日柱为 癸卯、癸巳、丁酉、丁亥
         */
        if (in_array($rizhu, ['癸卯', '癸巳', '丁酉', '丁亥'], true))
        {
            $res[] = 16;
        }
        /**
         * 日德格
         *  日柱为甲辰、丙辰、戊辰、庚辰、壬戌，其它柱也存在这五柱之一
         */
        if (in_array($rizhu, ['甲辰', '丙辰', '戊辰', '庚辰', '壬戌'], true)
            && (in_array($tiangan[0] . $dizhi[0], ['甲辰', '丙辰', '戊辰', '庚辰', '壬戌'], true)
                || in_array($tiangan[1] . $dizhi[1], ['甲辰', '丙辰', '戊辰', '庚辰', '壬戌'], true)
                || in_array($tiangan[3] . $dizhi[3], ['甲辰', '丙辰', '戊辰', '庚辰', '壬戌'], true)))
        {
            $res[] = 17;
        }
        /**
         * 曲直仁寿格
         *  日干为甲或乙，月令为亥寅卯未之一，其余地支均是亥子寅卯辰未之一，且四地支必须有寅卯之一，八字中必须有壬癸亥子之一，八字中不可有庚辛申酉字
         */
        if (in_array($rigan, ['甲', '乙'], true)
            && in_array($dizhi[1], ['亥', '寅', '卯', '未'], true)
            && in_array($dizhi[0], ['亥', '子', '寅', '卯', '辰', '未'], true)
            && in_array($dizhi[2], ['亥', '子', '寅', '卯', '辰', '未'], true)
            && in_array($dizhi[3], ['亥', '子', '寅', '卯', '辰', '未'], true)
            && (in_array($dizhi[0], ['寅', '卯'], true)
                || in_array($dizhi[1], ['寅', '卯'], true)
                || in_array($dizhi[2], ['寅', '卯'], true)
                || in_array($dizhi[3], ['寅', '卯'], true))
            && (in_array('壬', $bazi, true)
                || in_array('癸', $bazi, true)
                || in_array('亥', $bazi, true)
                || in_array('子', $bazi, true))
            && !in_array('庚', $bazi, true)
            && !in_array('辛', $bazi, true)
            && !in_array('申', $bazi, true)
            && !in_array('酉', $bazi, true))
        {
            $res[] = 18;
        }
        /**
         * 炎上格
         *  日干为丙或丁，月令为寅巳午戌之一，其余地支均是寅卯巳午未戌之一，且四地支必须有巳午之一，八字中必须有甲乙寅卯之一，八字中不可有亥子字
         */
        if (in_array($rigan, ['丙', '丁'], true)
            && in_array($dizhi[1], ['寅', '巳', '午', '戌'], true)
            && in_array($dizhi[0], ['寅', '卯', '巳', '午', '未', '戌'], true)
            && in_array($dizhi[2], ['寅', '卯', '巳', '午', '未', '戌'], true)
            && in_array($dizhi[3], ['寅', '卯', '巳', '午', '未', '戌'], true)
            && (in_array($dizhi[0], ['巳', '午'], true)
                || in_array($dizhi[1], ['巳', '午'], true)
                || in_array($dizhi[2], ['巳', '午'], true)
                || in_array($dizhi[3], ['巳', '午'], true))
            && (in_array('甲', $bazi, true)
                || in_array('乙', $bazi, true)
                || in_array('寅', $bazi, true)
                || in_array('卯', $bazi, true))
            && !in_array('亥', $bazi, true)
            && !in_array('子', $bazi, true))
        {
            $res[] = 19;
        }
        /**
         * 稼穑格
         *  日干为戊或己，四地支都是辰戌丑未之一，八字中不可有甲乙寅卯字
         */
        if (in_array($rigan, ['戊', '己'], true)
            && in_array($dizhi[0], ['辰', '戌', '丑', '未'], true)
            && in_array($dizhi[1], ['辰', '戌', '丑', '未'], true)
            && in_array($dizhi[2], ['辰', '戌', '丑', '未'], true)
            && in_array($dizhi[3], ['辰', '戌', '丑', '未'], true)
            && !in_array('甲', $bazi, true)
            && !in_array('乙', $bazi, true)
            && !in_array('寅', $bazi, true)
            && !in_array('卯', $bazi, true))
        {
            $res[] = 20;
        }
        /**
         * 润下格
         *  日干为壬或癸，月令为申亥子辰之一，其余地支均是申酉亥子丑辰之一，且四地支必须有亥子之一，酉字不能多于一位，八字中不可有戊己戌未巳午字
         */
        if (in_array($rigan, ['壬', '癸'], true)
            && in_array($dizhi[1], ['申', '亥', '子', '辰'], true)
            && in_array($dizhi[0], ['申', '酉', '亥', '子', '丑', '辰'], true)
            && in_array($dizhi[2], ['申', '酉', '亥', '子', '丑', '辰'], true)
            && in_array($dizhi[3], ['申', '酉', '亥', '子', '丑', '辰'], true)
            && (in_array($dizhi[0], ['亥', '子'], true)
                || in_array($dizhi[1], ['亥', '子'], true)
                || in_array($dizhi[2], ['亥', '子'], true)
                || in_array($dizhi[3], ['亥', '子'], true))
            && (!isset($baziRepeatCount['酉']) || $baziRepeatCount['酉'] <= 1)
            && !in_array('戊', $bazi, true)
            && !in_array('己', $bazi, true)
            && !in_array('戌', $bazi, true)
            && !in_array('未', $bazi, true)
            && !in_array('巳', $bazi, true)
            && !in_array('午', $bazi, true))
        {
            $res[] = 21;
        }
        /**
         * 从革格
         *  日干为庚或辛，月令为申酉丑之一，其余地支均是巳申酉丑戌之一，且四地支必须有申酉之一，戌巳字不能多于一位，八字中不可有丙丁巳午未字
         */
        if (in_array($rigan, ['庚', '辛'], true)
            && in_array($dizhi[1], ['申', '酉', '丑'], true)
            && in_array($dizhi[0], ['巳', '申', '酉', '丑', '戌'], true)
            && in_array($dizhi[2], ['巳', '申', '酉', '丑', '戌'], true)
            && in_array($dizhi[3], ['巳', '申', '酉', '丑', '戌'], true)
            && (in_array($dizhi[0], ['申', '酉'], true)
                || in_array($dizhi[1], ['申', '酉'], true)
                || in_array($dizhi[2], ['申', '酉'], true)
                || in_array($dizhi[3], ['申', '酉'], true))
            && (!isset($baziRepeatCount['戌']) || $baziRepeatCount['戌'] <= 1)
            && (!isset($baziRepeatCount['巳']) || $baziRepeatCount['巳'] <= 1)
            && !in_array('丙', $bazi, true)
            && !in_array('丁', $bazi, true)
            && !in_array('巳', $bazi, true)
            && !in_array('午', $bazi, true)
            && !in_array('未', $bazi, true))
        {
            $res[] = 22;
        }
        /**
         * 丁壬化木格
         *  日干是丁或壬，同时月干或时干与日干五合，月令是亥寅卯未之一，地支有寅卯之一，八字中无庚辛申酉丑（如天干有辛必须天干有丙）
         */
        if (in_array($rigan, ['丁', '壬'], true)
            && ($this->is_wuhe($tiangan[1], $rigan)
                || $this->is_wuhe($tiangan[3], $rigan))
            && in_array($dizhi[1], ['亥', '寅', '卯', '未'], true)
            && (in_array($dizhi[0], ['寅', '卯'], true)
                || in_array($dizhi[1], ['寅', '卯'], true)
                || in_array($dizhi[2], ['寅', '卯'], true)
                || in_array($dizhi[3], ['寅', '卯'], true))
            && !in_array('庚', $bazi, true)
            && (!in_array('辛', $bazi, true)
                || (in_array('辛', $bazi, true)
                    && in_array('丙', $bazi, true)))
            && !in_array('申', $bazi, true)
            && !in_array('酉', $bazi, true)
            && !in_array('丑', $bazi, true))
        {
            $res[] = 23;
        }
        /**
         * 戊癸化火格
         *  日干是戊或癸，同时月干或时干与日干五合，月令是寅巳午未戌之一，地支有巳午之一，八字中无壬亥子辰（如天干有壬必须天干有丁，天干不可有两个癸）
         */
        if (in_array($rigan, ['戊', '癸'], true)
            && ($this->is_wuhe($tiangan[1], $rigan)
                || $this->is_wuhe($tiangan[3], $rigan))
            && in_array($dizhi[1], ['寅', '巳', '午', '未', '戌'], true)
            && (in_array($dizhi[0], ['巳', '午'], true)
                || in_array($dizhi[1], ['巳', '午'], true)
                || in_array($dizhi[2], ['巳', '午'], true)
                || in_array($dizhi[3], ['巳', '午'], true))
            && (!in_array('壬', $bazi, true)
                || (in_array('壬', $bazi, true)
                    && in_array('丁', $bazi, true)))
            && !in_array('亥', $bazi, true)
            && !in_array('子', $bazi, true)
            && !in_array('辰', $bazi, true)
            && (!isset($baziRepeatCount['癸']) || $baziRepeatCount['癸'] <= 1))
        {
            $res[] = 24;
        }
        /**
         * 甲己化土格
         *  日干是甲或己，同时月干或时干与日干五合，月令是辰戌丑未巳午之一，地支有巳午之一，八字中无乙寅卯（如天干有乙必须天干有庚，天干不可有两个甲）
         */
        if (in_array($rigan, ['甲', '己'], true)
            && ($this->is_wuhe($tiangan[1], $rigan)
                || $this->is_wuhe($tiangan[3], $rigan))
            && in_array($dizhi[1], ['辰', '戌', '丑', '未', '巳', '午'], true)
            && (in_array($dizhi[0], ['巳', '午'], true)
                || in_array($dizhi[1], ['巳', '午'], true)
                || in_array($dizhi[2], ['巳', '午'], true)
                || in_array($dizhi[3], ['巳', '午'], true))
            && (!in_array('乙', $bazi, true)
                || (in_array('乙', $bazi, true)
                    && in_array('庚', $bazi, true)))
            && !in_array('寅', $bazi, true)
            && !in_array('卯', $bazi, true)
            && (!isset($baziRepeatCount['甲']) || $baziRepeatCount['甲'] <= 1))
        {
            $res[] = 25;
        }
        /**
         * 乙庚化金格
         *  日干是乙或庚，同时月干或时干与日干五合，月令是申酉丑之一，地支有申酉之一，八字中无丙丁午（如天干有丙必须天干有辛）
         */
        if (in_array($rigan, ['乙', '庚'], true)
            && ($this->is_wuhe($tiangan[1], $rigan)
                || $this->is_wuhe($tiangan[3], $rigan))
            && in_array($dizhi[1], ['申', '酉', '丑'], true)
            && (in_array($dizhi[0], ['申', '酉'], true)
                || in_array($dizhi[1], ['申', '酉'], true)
                || in_array($dizhi[2], ['申', '酉'], true)
                || in_array($dizhi[3], ['申', '酉'], true))
            && (!in_array('丙', $bazi, true)
                || (in_array('丙', $bazi, true)
                    && in_array('辛', $bazi, true)))
            && !in_array('丁', $bazi, true)
            && !in_array('午', $bazi, true))
        {
            $res[] = 26;
        }
        /**
         * 丙辛化水格
         *  日干是丙或辛，同时月干或时干与日干五合，月令是申亥子辰之一，地支有亥子之一，八字中无戊己戌未
         */
        if (in_array($rigan, ['丙', '辛'], true)
            && ($this->is_wuhe($tiangan[1], $rigan)
                || $this->is_wuhe($tiangan[3], $rigan))
            && in_array($dizhi[1], ['申', '亥', '子', '辰'], true)
            && (in_array($dizhi[0], ['亥', '子'], true)
                || in_array($dizhi[1], ['亥', '子'], true)
                || in_array($dizhi[2], ['亥', '子'], true)
                || in_array($dizhi[3], ['亥', '子'], true))
            && !in_array('戊', $bazi, true)
            && !in_array('己', $bazi, true)
            && !in_array('戌', $bazi, true)
            && !in_array('未', $bazi, true))
        {
            $res[] = 27;
        }

        /**
         * 日刃格
         *  日支为羊刃，非戊己日
         */
        if ($shensha['羊刃'][$rigan] === $dizhi[2] && !in_array($rigan, ['戊', '己'], true))
        {
            $res[] = 28;
        } /**
         * 时刃格
         *  时支为羊刃，非戊己日，非日刃格
         */
        elseif ($shensha['羊刃'][$rigan] === $dizhi[3] && !in_array($rigan[2], ['戊', '己'], true))
        {
            $res[] = 29;
        }
        /**
         * 日禄格
         *  日支为禄神，非戊己日
         */
        if ($shensha['禄神'][$rigan] === $dizhi[2] && !in_array($rigan, ['戊', '己'], true))
        {
            $res[] = 30;
        }
        /**
         * 时墓格
         *  时支为日主的财官库
         *    日主木，财官库是丑戌，日主火 财官库是丑辰，日主土，辰未，日主金，未戌，日主水，戌
         */
        $riganWx = $this->param['wuxing'][$rigan];
        if (($riganWx === '水' && $dizhi[3] === '戌')
            || ($riganWx === '木' && in_array($dizhi[3], ['丑', '戌'], true))
            || ($riganWx === '火' && in_array($dizhi[3], ['丑', '辰'], true))
            || ($riganWx === '土' && in_array($dizhi[3], ['辰', '未'], true))
            || ($riganWx === '金' && in_array($dizhi[3], ['未', '戌'], true)))
        {
            $res[] = 31;
        }
        /**
         * 禄马同乡
         *  壬午，癸巳两日
         */
        if (in_array($rizhu, ['壬午', '癸巳'], true))
        {
            $res[] = 32;
        }
        /**
         * 天元暗禄
         *  庚寅、乙巳、丙申、己亥四日
         */
        if (in_array($rizhu, ['庚寅', '乙巳', '丙申', '己亥'], true))
        {
            $res[] = 33;
        }
        /**
         * 子午双包
         *  年时支均为子，月日支均为午，或年时午月日子，或月时子日午，或月时午日子
         */
        if (($dizhi[0] === '子' && $dizhi[3] === '子' && $dizhi[1] === '午' && $dizhi[2] === '午')
            || ($dizhi[0] === '子' && $dizhi[1] === '子' && $dizhi[2] === '子' && $dizhi[3] === '子')
            || ($dizhi[1] === '子' && $dizhi[3] === '子' && $dizhi[2] === '午')
            || ($dizhi[1] === '午' && $dizhi[3] === '午' && $dizhi[2] === '子'))
        {
            $res[] = 34;
        }
        /**
         * 天地德合（时）
         *  时柱与年柱干合支合
         */
        if ($this->is_wuhe($tiangan[3], $tiangan[0])
            && ($this->is_liuhe($dizhi[3], $dizhi[0])
                || $this->is_anhe($dizhi[3], $dizhi[0])))
        {
            $res[] = 35;
        }
        /**
         * 天地德合
         *  四柱中某两柱干合支合，非年时
         */
        if (($this->is_wuhe($tiangan[1], $tiangan[0])
                && ($this->is_liuhe($dizhi[1], $dizhi[0])
                    || $this->is_anhe($dizhi[1], $dizhi[0])))
            || ($this->is_wuhe($tiangan[2], $tiangan[0])
                && ($this->is_liuhe($dizhi[2], $dizhi[0])
                    || $this->is_anhe($dizhi[2], $dizhi[0])))
            || ($this->is_wuhe($tiangan[2], $tiangan[1])
                && ($this->is_liuhe($dizhi[2], $dizhi[1])
                    || $this->is_anhe($dizhi[2], $dizhi[1])))
            || ($this->is_wuhe($tiangan[2], $tiangan[3])
                && ($this->is_liuhe($dizhi[2], $dizhi[3])
                    || $this->is_anhe($dizhi[2], $dizhi[3]))))
        {
            $res[] = 36;
        }
        /**
         * 蝴蝶双飞
         *  日干支与年干支同，月干支与时干支同
         */
        if ($tiangan[2] === $tiangan[0] && $dizhi[2] === $dizhi[0] && $tiangan[1] === $tiangan[3] && $dizhi[1] === $dizhi[3])
        {
            $res[] = 37;
        }
        /**
         * 正官逢贵
         *  天乙贵人所在的同柱干支本气有正官
         */
        // 天乙贵人 以年干或日干为参照
        $tianyiguiren1 = $shensha['天乙贵人'][$tiangan[0]];
        $tianyiguiren2 = $shensha['天乙贵人'][$tiangan[2]];
        if ((in_array($dizhi[1], $tianyiguiren1, true)
                && ($shishen[$rigan][$tiangan[1]] === '正官'
                    || $shishen[$rigan][$canggan[$dizhi[1]][0]] === '正官'))
            || (in_array($dizhi[2], $tianyiguiren1, true)
                && $shishen[$rigan][$canggan[$dizhi[2]][0]] === '正官')
            || ((in_array($dizhi[3], $tianyiguiren1, true)
                && ($shishen[$rigan][$tiangan[3]] === '正官'
                    || $shishen[$rigan][$canggan[$dizhi[3]][0]] === '正官')))
            || ((in_array($dizhi[0], $tianyiguiren2, true)
                && ($shishen[$rigan][$tiangan[0]] === '正官'
                    || $shishen[$rigan][$canggan[$dizhi[0]][0]] === '正官')))
            || ((in_array($dizhi[1], $tianyiguiren2, true)
                && ($shishen[$rigan][$tiangan[1]] === '正官'
                    || $shishen[$rigan][$canggan[$dizhi[1]][0]] === '正官')))
            || (in_array($dizhi[2], $tianyiguiren2, true)
                && $shishen[$rigan][$canggan[$dizhi[2]][0]] === '正官')
            || ((in_array($dizhi[3], $tianyiguiren2, true)
                && ($shishen[$rigan][$tiangan[3]] === '正官'
                    || $shishen[$rigan][$canggan[$dizhi[3]][0]] === '正官'))))
        {
            $res[] = 38;
        }
        /**
         * 藤萝系甲
         *  乙日干，天干见甲
         */
        if ($rigan === '乙' && in_array('甲', $tiangan, true))
        {
            $res[] = 39;
        }
        /**
         * 劈甲引丁
         *  天干同时出现庚甲丁，或，日时有庚寅或甲申 同时月日时有丁或午
         */
        if ((in_array('庚', $tiangan, true)
                && in_array('甲', $tiangan, true)
                && in_array('丁', $tiangan, true))
            || (($tiangan[2] === '庚' && $dizhi[2] === '寅' && ($tiangan[1] === '丁' || $tiangan[2] === '丁' || $tiangan[3] === '丁'))
                || ($tiangan[2] === '甲' && $dizhi[2] === '申' && ($tiangan[1] === '午' || $tiangan[2] === '午' || $tiangan[3] === '午'))
                || ($tiangan[3] === '庚' && $dizhi[3] === '寅' && ($tiangan[1] === '丁' || $tiangan[2] === '丁' || $tiangan[3] === '丁'))
                || ($tiangan[3] === '甲' && $dizhi[3] === '申' && ($tiangan[1] === '午' || $tiangan[2] === '午' || $tiangan[3] === '午'))))
        {
            $res[] = 40;
        }
        /**
         * 羊击猪蛇
         *  日柱辛未或癸未，其它地支也有未，且有申酉丑之一
         */
        if (($dizhi[0] === '未' || $dizhi[1] === '未' || $dizhi[3] === '未')
            && in_array($rizhu, ['辛未', '癸未'], true)
            && (in_array('申', $dizhi, true)
                || in_array('酉', $dizhi, true)
                || in_array('丑', $dizhi, true))
        )
        {
            $res[] = 41;
        }
        /**
         * 虎牛奔巳
         *  辛日或癸日，地支有寅丑酉三字，不见申巳
         */
        if (($rigan === '辛' || $rigan === '癸')
            && (in_array('寅', $dizhi, true)
                || in_array('酉', $dizhi, true)
                || in_array('丑', $dizhi, true))
            && !in_array('申', $dizhi, true)
            && !in_array('巳', $dizhi, true))
        {
            $res[] = 42;
        }
        /**
         * 六壬趋艮
         *  壬日寅时，地支不见申亥
         */
        if ($rigan === '壬' && $dizhi[3] === '寅'
            && !in_array('申', $dizhi, true)
            && !in_array('亥', $dizhi, true))
        {
            $res[] = 43;
        } /**
         * 六甲趋乾
         *  甲日亥时，地支不见寅巳
         */
        elseif ($rigan === '甲' && $dizhi[3] === '亥'
            && !in_array('寅', $dizhi, true)
            && !in_array('亥', $dizhi, true))
        {
            $res[] = 44;
        }
        /**
         * 天元一气
         *  年月日时天干相同
         */
        if ($tiangan[0] === $tiangan[1] && $tiangan[1] === $tiangan[2] && $tiangan[2] === $tiangan[3])
        {
            $res[] = 45;
        }
        /**
         * 木火通明
         *  木日主或火日主，木火都有本气根，都在天干明见（包括日干），不见金水的明干和本气
         */
        $wxList = [
            '木' => [
                'tiangan_num' => 0,
                'benqi_num' => 0,
                'benqi_mingjian' => false,
            ],
            '火' => [
                'tiangan_num' => 0,
                'benqi_num' => 0,
                'benqi_mingjian' => false,
            ],
            '土' => [
                'tiangan_num' => 0,
                'benqi_num' => 0,
                'benqi_mingjian' => false,
            ],
            '金' => [
                'tiangan_num' => 0,
                'benqi_num' => 0,
                'benqi_mingjian' => false,
            ],
            '水' => [
                'tiangan_num' => 0,
                'benqi_num' => 0,
                'benqi_mingjian' => false,
            ],
        ];
        foreach ($tiangan as $k1 => $v1)
        {
            $wx = $this->param['wuxing'][$v1];
            $wxList[$wx]['tiangan_num']++;
        }
        foreach ($dizhi as $k1 => $v1)
        {
            $benqi = $canggan[$v1][0];
            $benqiWx = $this->param['wuxing'][$benqi];
            $wxList[$benqiWx]['benqi_num']++;
            if (in_array($benqi, $tiangan, true))
            {
                $wxList[$benqiWx]['benqi_mingjian'] = true;
            }
        }
        if (in_array($riganWx, ['木', '火'], true)
            && $wxList['木']['benqi_num'] > 0
            && $wxList['火']['benqi_num'] > 0
            && $wxList['木']['benqi_mingjian']
            && $wxList['火']['benqi_mingjian']
            && $wxList['金']['tiangan_num'] === 0
            && $wxList['水']['tiangan_num'] === 0
            && $wxList['金']['benqi_num'] === 0
            && $wxList['水']['benqi_num'] === 0)
        {
            $res[] = 46;
        } /**
         * 金白水清
         *  金日主或水日主，金水都有本气根，都在天干明见（包括日干），不见火土的明干和本气
         */
        elseif (in_array($riganWx, ['金', '水'], true)
            && $wxList['金']['benqi_num'] > 0
            && $wxList['水']['benqi_num'] > 0
            && $wxList['金']['benqi_mingjian']
            && $wxList['水']['benqi_mingjian']
            && $wxList['火']['tiangan_num'] === 0
            && $wxList['土']['tiangan_num'] === 0
            && $wxList['火']['benqi_num'] === 0
            && $wxList['土']['benqi_num'] === 0)
        {
            $res[] = 47;
        } /**
         * 土金毓秀
         *  土日主或金日主，土金都有本气根，都在天干明见（包括日干），不见木火的明干和本气
         */
        elseif (in_array($riganWx, ['土', '金'], true)
            && $wxList['土']['benqi_num'] > 0
            && $wxList['金']['benqi_num'] > 0
            && $wxList['土']['benqi_mingjian']
            && $wxList['金']['benqi_mingjian']
            && $wxList['木']['tiangan_num'] === 0
            && $wxList['火']['tiangan_num'] === 0
            && $wxList['木']['benqi_num'] === 0
            && $wxList['火']['benqi_num'] === 0)
        {
            $res[] = 48;
        } /**
         * 水清木华
         *  水日主或木日主，水木都有本气根，都在天干明见（包括日干），不见土金的明干和本气
         */
        elseif (in_array($riganWx, ['水', '木'], true)
            && $wxList['水']['benqi_num'] > 0
            && $wxList['木']['benqi_num'] > 0
            && $wxList['水']['benqi_mingjian']
            && $wxList['木']['benqi_mingjian']
            && $wxList['土']['tiangan_num'] === 0
            && $wxList['金']['tiangan_num'] === 0
            && $wxList['土']['benqi_num'] === 0
            && $wxList['金']['benqi_num'] === 0)
        {
            $res[] = 49;
        }
        /**
         * 天干顺食
         *  年月日时，天干同性且依次相生
         */
        $sheng = [
            '甲' => ['丙', '丁'],
            '乙' => ['丙', '丁'],
            '丙' => ['戊', '己'],
            '丁' => ['戊', '己'],
            '戊' => ['庚', '辛'],
            '己' => ['庚', '辛'],
            '庚' => ['壬', '癸'],
            '辛' => ['壬', '癸'],
            '壬' => ['甲', '丁'],
            '癸' => ['甲', '乙'],
        ];
        if ($this->param['wuxing_yinyang'][$tiangan[0]] === $this->param['wuxing_yinyang'][$tiangan[1]]
            && $this->param['wuxing_yinyang'][$tiangan[1]] === $this->param['wuxing_yinyang'][$tiangan[2]]
            && $this->param['wuxing_yinyang'][$tiangan[2]] === $this->param['wuxing_yinyang'][$tiangan[3]]
            && in_array($tiangan[1], $sheng[$tiangan[0]], true)
            && in_array($tiangan[2], $sheng[$tiangan[1]], true)
            && in_array($tiangan[3], $sheng[$tiangan[2]], true))
        {
            $res[] = 50;
        }
        /**
         * 三奇真贵
         *  财（或才）官印同时在天干出现，
         */
        $shishens = [
            '甲' => [
                '比肩' => '甲',
                '劫财' => '乙',
                '食神' => '丙',
                '伤官' => '丁',
                '偏财' => '戊',
                '正财' => '己',
                '七杀' => '庚',
                '正官' => '辛',
                '偏印' => '壬',
                '正印' => '癸',
            ],
            '乙' => [
                '劫财' => '甲',
                '比肩' => '乙',
                '伤官' => '丙',
                '食神' => '丁',
                '正财' => '戊',
                '偏财' => '己',
                '正官' => '庚',
                '七杀' => '辛',
                '正印' => '壬',
                '偏印' => '癸',
            ],
            '丙' => [
                '偏印' => '甲',
                '正印' => '乙',
                '比肩' => '丙',
                '劫财' => '丁',
                '食神' => '戊',
                '伤官' => '己',
                '偏财' => '庚',
                '正财' => '辛',
                '七杀' => '壬',
                '正官' => '癸',
            ],
            '丁' => [
                '正印' => '甲',
                '偏印' => '乙',
                '劫财' => '丙',
                '比肩' => '丁',
                '伤官' => '戊',
                '食神' => '己',
                '正财' => '庚',
                '偏财' => '辛',
                '正官' => '壬',
                '七杀' => '癸',
            ],
            '戊' => [
                '七杀' => '甲',
                '正官' => '乙',
                '偏印' => '丙',
                '正印' => '丁',
                '比肩' => '戊',
                '劫财' => '己',
                '食神' => '庚',
                '伤官' => '辛',
                '偏财' => '壬',
                '正财' => '癸',
            ],
            '己' => [
                '正官' => '甲',
                '七杀' => '乙',
                '正印' => '丙',
                '偏印' => '丁',
                '劫财' => '戊',
                '比肩' => '己',
                '伤官' => '庚',
                '食神' => '辛',
                '正财' => '壬',
                '偏财' => '癸',
            ],
            '庚' => [
                '偏财' => '甲',
                '正财' => '乙',
                '七杀' => '丙',
                '正官' => '丁',
                '偏印' => '戊',
                '正印' => '己',
                '比肩' => '庚',
                '劫财' => '辛',
                '食神' => '壬',
                '伤官' => '癸',
            ],
            '辛' => [
                '正财' => '甲',
                '偏财' => '乙',
                '正官' => '丙',
                '七杀' => '丁',
                '正印' => '戊',
                '偏印' => '己',
                '劫财' => '庚',
                '比肩' => '辛',
                '伤官' => '壬',
                '食神' => '癸',
            ],
            '壬' => [
                '食神' => '甲',
                '伤官' => '乙',
                '偏财' => '丙',
                '正财' => '丁',
                '七杀' => '戊',
                '正官' => '己',
                '偏印' => '庚',
                '正印' => '辛',
                '比肩' => '壬',
                '劫财' => '癸',
            ],
            '癸' => [
                '伤官' => '甲',
                '食神' => '乙',
                '正财' => '丙',
                '偏财' => '丁',
                '正官' => '戊',
                '七杀' => '己',
                '正印' => '庚',
                '偏印' => '辛',
                '劫财' => '壬',
                '比肩' => '癸',
            ],
        ];
        $zhengguanGan = $shishens[$rigan]['正官'];
        $zhengyinGan = $shishens[$rigan]['正印'];
        $zhengcaiGan = $shishens[$rigan]['正财'];
        $piancaiGan = $shishens[$rigan]['偏财'];
        if ((in_array($zhengcaiGan, $tiangan, true) || in_array($piancaiGan, $tiangan, true))
            && in_array($zhengguanGan, $tiangan, true) && in_array($zhengyinGan, $tiangan, true))
        {
            $res[] = 51;
        }
        /**
         * 五气流通
         *  年月日时天干依次相生，或地支本气依次相生（时日月年顺序也可）
         */
        if ((in_array($tiangan[1], $sheng[$tiangan[0]], true)
                && in_array($tiangan[2], $sheng[$tiangan[1]], true)
                && in_array($tiangan[3], $sheng[$tiangan[2]], true))
            || (in_array($canggan[$dizhi[1]][0], $sheng[$canggan[$dizhi[0]][0]], true)
                && in_array($canggan[$dizhi[2]][0], $sheng[$canggan[$dizhi[1]][0]], true)
                && in_array($canggan[$dizhi[3]][0], $sheng[$canggan[$dizhi[2]][0]], true))
            || (in_array($tiangan[2], $sheng[$tiangan[3]], true)
                && in_array($tiangan[1], $sheng[$tiangan[2]], true)
                && in_array($tiangan[0], $sheng[$tiangan[1]], true))
            || (in_array($canggan[$dizhi[2]][0], $sheng[$canggan[$dizhi[3]][0]], true)
                && in_array($canggan[$dizhi[1]][0], $sheng[$canggan[$dizhi[2]][0]], true)
                && in_array($canggan[$dizhi[0]][0], $sheng[$canggan[$dizhi[1]][0]], true))
        )
        {
            $res[] = 52;
        }
        /**
         * 从财格
         *  日干至多一个非本气根，财星透干且极旺
         */
        $riganFeiBenqiGenNum = 0;
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                if ($k2 === 0) continue;
                if ($v2 === $rigan)
                {
                    $riganFeiBenqiGenNum++;
                }
            }
        }
        $HoroscopeFortune = HoroscopeFortune::getInstance()->setHoroscopeInstance($this)->setBazi($bazi);
        $tianganPower = $HoroscopeFortune->tianganPower();// 计算十天干气力值
        if ($riganFeiBenqiGenNum <= 1
            && (($tianganPower[$piancaiGan]['level'] === 5 && in_array($piancaiGan, $tiangan, true))
                || ($tianganPower[$zhengcaiGan]['level'] === 5 && in_array($zhengcaiGan, $tiangan, true))))
        {
            $res[] = 53;
        }
        /**
         * 从儿格
         *  日干至多一个非本气根，食伤透干且极旺
         */
        $shishenGan = $shishens[$rigan]['食神'];
        $shangguanGan = $shishens[$rigan]['伤官'];
        if ($riganFeiBenqiGenNum <= 1
            && (($tianganPower[$shishenGan]['level'] === 5 && in_array($shishenGan, $tiangan, true))
                || ($tianganPower[$shangguanGan]['level'] === 5 && in_array($shangguanGan, $tiangan, true))))
        {
            $res[] = 54;
        }
        /**
         * 从杀格
         *  日干至多一个非本气根，七杀透干且官杀极旺
         */
        $qishaGan = $shishens[$rigan]['七杀'];
        if ($riganFeiBenqiGenNum <= 1
            && ($tianganPower[$qishaGan]['level'] === 5
                || $tianganPower[$zhengguanGan]['level'] === 5)
            && in_array($qishaGan, $tiangan, true))
        {
            $res[] = 55;
        }
        /**
         * 阴众藏阳
         *  非未月生，干支本气水三个以上，不见明火，有戌无辰
         */
        $shuiNum = 0;
        $huoNum = 0;
        $mingShuiNum = 0;
        $mingHuoNum = 0;
        foreach ($tiangan as $k1 => $v1)
        {
            if ($this->param['wuxing'][$v1] === '水')
            {
                $shuiNum++;
                $mingShuiNum++;
            } elseif ($this->param['wuxing'][$v1] === '火')
            {
                $huoNum++;
                $mingHuoNum++;
            }
        }
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($canggan[$v1] as $k2 => $v2)
            {
                if ($k2 === 0)
                {
                    if ($this->param['wuxing'][$v2] === '水')
                    {
                        $shuiNum++;
                    } elseif ($this->param['wuxing'][$v2] === '火')
                    {
                        $huoNum++;
                    }
                }
            }
        }
        if ($dizhi[1] !== '未'
            && $shuiNum >= 3
            && $mingHuoNum === 0
            && in_array('戌', $dizhi, true)
            && !in_array('辰', $dizhi, true))
        {
            $res[] = 56;
        } /**
         * 阳众藏阴
         *  巳午未月生，干支本气火三个以上，土一个以上，不见明水，有辰无戌
         */
        elseif ($huoNum >= 3
            && $mingShuiNum === 0
            && in_array($dizhi[1], ['巳', '午', '未'], true)
            && !in_array('戌', $dizhi, true)
            && in_array('辰', $dizhi, true))
        {
            $res[] = 57;
        }
        /**
         * 贵人往来
         *  日干的的天乙贵人在年月时柱，该柱天干的天乙贵人在日支
         */
        if ((in_array($dizhi[0], $shensha['天乙贵人'][$rigan], true)
                && in_array($dizhi[2], $shensha['天乙贵人'][$tiangan[0]], true))
            || (in_array($dizhi[1], $shensha['天乙贵人'][$rigan], true)
                && in_array($dizhi[2], $shensha['天乙贵人'][$tiangan[1]], true))
            || (in_array($dizhi[3], $shensha['天乙贵人'][$rigan], true)
                && in_array($dizhi[2], $shensha['天乙贵人'][$tiangan[3]], true)))
        {
            $res[] = 58;
        }
        /**
         * 两神成象
         *  四柱干支本气仅有两个五行，且都有本气地支和透干
         */
        $baziwuxing = [];
        foreach ($tiangan as $k1 => $v1)
        {
            $wx = $this->param['wuxing'][$v1];
            if (!in_array($wx, $baziwuxing, true))
            {
                $baziwuxing[] = $wx;
            }
        }
        // 如以上外格皆没有，检测日柱，得以下格局其中之一
        if (empty($res))
        {
            $rizhibenqiShishen = $this->param['shishen'][$canggan[$dizhi[2]][0]][$rigan];
            /**
             * 抱印成慈
             *  日支本气正印
             */
            if ($rizhibenqiShishen === '正印')
            {
                $res[] = 60;
            } /**
             * 抱财成富
             *  日支本气正偏财或财库
             *     日坐财库:丁丑、戊辰、辛未、壬戌
             */
            elseif (in_array($rizhibenqiShishen, ['正财', '偏财'], true)
                && in_array($rizhu, ['丁丑', '戊辰', '辛未', '壬戌'], true))
            {
                $res[] = 61;
            } /**
             * 抱官成贵
             *  日支本气正官或官杀库
             *   木丑火辰土未金戌水戌(官杀库就是库神克日干的地支)
             */
            elseif ($rizhibenqiShishen === '正官'
                || (($riganWx === '水' && $dizhi[3] === '戌')
                    || ($riganWx === '木' && $dizhi[3] === '丑')
                    || ($riganWx === '火' && $dizhi[3] === '辰')
                    || ($riganWx === '土' && $dizhi[3] === '未')
                    || ($riganWx === '金' && $dizhi[3] === '戌')))
            {
                $res[] = 62;
            } /**
             * 抱杀成权
             *  日支本气七杀
             */
            elseif ($rizhibenqiShishen === '七杀')
            {
                $res[] = 63;
            } /**
             * 抱食成才
             *  日支本气食神或食伤库
             *   木戌火戌土丑金辰水未
             */
            elseif ($rizhibenqiShishen === '食神'
                || (($riganWx === '水' && $dizhi[3] === '未')
                    || ($riganWx === '木' && $dizhi[3] === '戌')
                    || ($riganWx === '火' && $dizhi[3] === '戌')
                    || ($riganWx === '土' && $dizhi[3] === '丑')
                    || ($riganWx === '金' && $dizhi[3] === '辰')))
            {
                $res[] = 64;
            } /**
             * 天慧格
             *  日支本气伤官或偏印
             */
            elseif ($rizhibenqiShishen === '伤官' || $rizhibenqiShishen === '偏印')
            {
                $res[] = 64;
            }
        }

        return $res;
    }

    /**
     * 查看八字间的关系 天干对天干  地支对地支
     * @param array $bazi [1=>年干,2=>年支,3=>月干,4=>月支,5=>日干,6=>日支,7=>时干,8=>时支]
     * @param array $dayun [0=>大运/小运天干,1=>大运/小运地支]
     * @param array $liunian [0=>流年天干,1=>流年地支]
     * @return array[]
     */
    public function baziGuanxi($bazi = [], $dayun = [], $liunian = [])
    {
        $res = ['tiangan' => [], 'dizhi' => [], 'tiangan_guanxi' => [], 'dizhi_guanxi' => []];
        // 八字中的所有天干
        $tiangan = [];
        // 八字中的所有地支
        $dizhi = [];
        foreach ($bazi as $k1 => $v1)
        {
            if ($k1 % 2 === 1)
            {
                $tiangan[] = $v1;
            } else
            {
                $dizhi[] = $v1;
            }
        }
        if (!empty($dayun))
        {
            $tiangan[] = $dayun[0];
            $dizhi[] = $dayun[1];
        }
        if (!empty($liunian))
        {
            $tiangan[] = $liunian[0];
            $dizhi[] = $liunian[1];
        }
        $res['tiangan'] = $tiangan;
        $res['dizhi'] = $dizhi;
        /**
         * 几种关系
         * 三合、合 绿色 #379964
         * 暗合、拱 蓝色 #4C6CE9 三合不论拱
         * 冲 红色 #CF6314
         * 刑害破 黑色 #303538
         * 优先顺序：三合、合、暗合、冲、刑、害、拱、破
         */
        $colors = [
            '三合' => '#379964',
            '三刑' => '#303538',
            '三会' => '#379964',
            '合' => '#379964',
            '六合' => '#379964',
            '五合' => '#379964',
            '暗合' => '#4C6CE9',
            '冲' => '#CF6314',
            '刑' => '#303538',
            '害' => '#303538',
            '拱' => '#4C6CE9',
            '破' => '#303538',
        ];
        foreach ($tiangan as $k1 => $v1)
        {
            foreach ($tiangan as $k2 => $v2)
            {
                if ($k1 >= $k2) continue;
                if ($this->is_wuhe($v1, $v2))
                {
                    $res['tiangan_guanxi'][] = [
                        'guanxi' => '合',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '合',
                        'color' => $colors['五合'],
                        'sort' => 2,
                    ];
                }
            }
        }
        foreach ($dizhi as $k1 => $v1)
        {
            foreach ($dizhi as $k2 => $v2)
            {
                if ($k1 >= $k2) continue;
                foreach ($dizhi as $k3 => $v3)
                {
                    if ($k2 >= $k3) continue;
                    $sanhe = $this->is_sanhe($v1, $v2, $v3);
                    if ($sanhe !== '')
                    {
                        $res['dizhi_guanxi'][] = [
                            'guanxi' => '三合',
                            'name_list' => [$v1, $v2, $v3],
                            'index_list' => [$k1, $k2, $k3],
                            'name' => '三合' . $sanhe . '局',
                            'color' => $colors['三合'],
                            'sort' => 1,
                        ];
                    }
                    $sanhui = $this->is_sanhui($v1, $v2, $v3);
                    if ($sanhui !== '')
                    {
                        $res['dizhi_guanxi'][] = [
                            'guanxi' => '三会',
                            'name_list' => [$v1, $v2, $v3],
                            'index_list' => [$k1, $k2, $k3],
                            'name' => '三会' . $sanhui . '局',
                            'color' => $colors['三会'],
                            'sort' => 1,
                        ];
                    }
                    if ($this->is_sanxing($v1, $v2, $v3))
                    {
                        $res['dizhi_guanxi'][] = [
                            'guanxi' => '三刑',
                            'name_list' => [$v1, $v2, $v3],
                            'index_list' => [$k1, $k2, $k3],
                            'name' => $this->dealNameSort([$v1, $v2, $v3]) . '三刑',
                            'color' => $colors['三刑'],
                            'sort' => 1,
                        ];
                    }
                }
                if ($this->is_liuhe($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '六合',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '相合',
                        'color' => $colors['六合'],
                        'sort' => 2,
                    ];
                }
                if ($this->is_anhe($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '暗合',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '暗合',
                        'color' => $colors['暗合'],
                        'sort' => 3,
                    ];
                }
                if ($this->is_liuchong($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '冲',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '相冲',
                        'color' => $colors['冲'],
                        'sort' => 4,
                    ];
                }
                if ($this->is_xing($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '刑',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '相刑',
                        'color' => $colors['刑'],
                        'sort' => 5,
                    ];
                }
                if ($this->is_liuhai($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '六害',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '相害',
                        'color' => $colors['害'],
                        'sort' => 6,
                    ];
                }
                if ($this->is_gong($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '拱',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '相拱',
                        'color' => $colors['拱'],
                        'sort' => 7,
                    ];
                }
                if ($this->is_liupo($v1, $v2))
                {
                    $res['dizhi_guanxi'][] = [
                        'guanxi' => '六破',
                        'name_list' => [$v1, $v2],
                        'index_list' => [$k1, $k2],
                        'name' => $this->dealNameSort([$v1, $v2]) . '相破',
                        'color' => $colors['破'],
                        'sort' => 8,
                    ];
                }
            }
        }
        $res['dizhi_guanxi'] = resort($res['dizhi_guanxi'], 'sort', 'ASC');
        return $res;
    }

    /**
     * 八字生肖
     * @param null $zhi 年支
     * @return string
     */
    public function baziShengxiao($zhi = null)
    {
        // 子（鼠）、丑（牛）、寅（虎）、卯（兔）、辰（龙）、巳（蛇）、午（马）、未（羊）、申（猴）、酉（鸡）、戌（狗）、亥（猪）
        switch ($zhi)
        {
            case '子':
                $res = '鼠';
                break;
            case '丑':
                $res = '牛';
                break;
            case '寅':
                $res = '虎';
                break;
            case '卯':
                $res = '兔';
                break;
            case '辰':
                $res = '龙';
                break;
            case '巳':
                $res = '蛇';
                break;
            case '午':
                $res = '马';
                break;
            case '未':
                $res = '羊';
                break;
            case '申':
                $res = '猴';
                break;
            case '酉':
                $res = '鸡';
                break;
            case '戌':
                $res = '狗';
                break;
            case '亥':
                $res = '猪';
                break;
            default:
                $res = '';
                break;
        }
        return $res;
    }

    /**
     * 八字命宫
     * @param array $bazi
     */
    public function baziMinggong($bazi = [])
    {
        $res = ['', ''];
        $dizhiList = [1 => '子', 2 => '丑', 3 => '寅', 4 => '卯', 5 => '辰', 6 => '巳', 7 => '午', 8 => '未', 9 => '申', 10 => '酉', 11 => '戌', 12 => '亥'];
        /**
         * 命宫
         * 设子1丑2寅3卯4……亥12
         * 计算
         * 32-月令数-时辰数
         * 对12取余
         * 确定地支
         * 按年干起月法（五虎遁）起天干
         */
        $yuelingShu = array_search($bazi[4], $dizhiList, true);
        $shichenShu = array_search($bazi[8], $dizhiList, true);
        $x = (32 - $yuelingShu - $shichenShu) % 12;
        if ($x === 0)
        {
            $dizhi = '亥';
        } else
        {
            $dizhi = $dizhiList[$x];
        }

        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 十二个月
        $temp = ['寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥', '子', '丑'];

        // $temp2 = ["丙","戊","庚","壬","甲","丙","戊","庚","壬","甲"];
        $temp2 = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0];

        $year_stem = $bazi[1];

        $year_num = array_search($year_stem, $Heavenly_Stems, true);

        $start_num = $temp2[$year_num];

        $branche_num = array_search($dizhi, $temp, true);

        $newArr = array_merge($Heavenly_Stems, $Heavenly_Stems, $Heavenly_Stems);

        $s = [];

        for ($i = $start_num; $i < $start_num + 12; $i++) $s[] = $newArr[$i];

        $res[0] = $s[$branche_num];

        $res[1] = $dizhi;

        return $res;
    }

    /**
     * 八字胎元
     * @param array $bazi
     */
    public function baziTaiyuan($bazi = [])
    {
        $res = [];
        /**
         * 胎元
         * 月干后一位为胎元天干
         * 月之后三位为胎元地支
         */
        $yueganIndex = array_search($bazi[3], $this->param['heavenly_stems'], true);
        $yueZhiIndex = array_search($bazi[4], $this->param['earthly_branches'], true);
        $yueganIndex++;
        $yueZhiIndex += 3;
        if ($yueganIndex > 9) $yueganIndex -= 9;
        if ($yueZhiIndex > 11) $yueZhiIndex -= 11;
        $res[0] = $this->param['heavenly_stems'][$yueganIndex];
        $res[1] = $this->param['earthly_branches'][$yueZhiIndex];
        return $res;
    }

    /**
     * 八字司令
     * @param int $sunDeg 太阳度数
     */
    public function baziSiling($sunDeg = 0)
    {
        $res = '';
        /**
         * 确定一个八字的司令，往前推一下哪天进入该月令，从那一天开始数，看他出生在进入该月令的第几天，对照这个表
         * 农历   地支  十二月令
         * 一月   寅    315˚立春后戊土七日322、丙火七日329、甲木十六日
         * 二月   卯    345˚惊蛰后甲木十日355、乙木二十日355~360 0~15
         * 三月   辰    15˚清明后乙木九日24、癸水三日27、戊土十八日
         * 四月   巳    45˚立夏后戊土五日50、庚金九日59、丙火十六日
         * 五月   午    75˚芒种后丙火十日85、己土九日94、丁火十一日
         * 六月   未    105˚小暑后丁火九日114、乙木三日117、己土十八日
         * 七月   申    135˚立秋后戊土十日145、壬水三日148、庚金十七日
         * 八月   酉    165˚白露后庚金十日175、辛金二十日
         * 九月   戌    195˚寒露后辛金九日204、丁火三日207、戊土十八日
         * 十月   亥    225˚立冬后戊土七日232、甲木五日237、壬水十八日
         * 十一月 子    255˚大雪后壬水十日265、癸水二十日
         * 十二月 丑    285˚小寒后癸水九日294、辛金三日297、己土十八日
         */
        if ($sunDeg >= 0 && $sunDeg < 15)
        {
            $res = '乙木';
        } elseif ($sunDeg >= 15 && $sunDeg < 24)
        {
            $res = '乙木';
        } elseif ($sunDeg >= 24 && $sunDeg < 27)
        {
            $res = '癸水';
        } elseif ($sunDeg >= 27 && $sunDeg < 45)
        {
            $res = '丙火';
        } elseif ($sunDeg >= 45 && $sunDeg < 50)
        {
            $res = '戊土';
        } elseif ($sunDeg >= 50 && $sunDeg < 59)
        {
            $res = '庚金';
        } elseif ($sunDeg >= 59 && $sunDeg < 75)
        {
            $res = '丙火';
        } elseif ($sunDeg >= 75 && $sunDeg < 85)
        {
            $res = '丙火';
        } elseif ($sunDeg >= 85 && $sunDeg < 94)
        {
            $res = '己土';
        } elseif ($sunDeg >= 94 && $sunDeg < 105)
        {
            $res = '丁火';
        } elseif ($sunDeg >= 105 && $sunDeg < 114)
        {
            $res = '丁火';
        } elseif ($sunDeg >= 114 && $sunDeg < 117)
        {
            $res = '乙木';
        } elseif ($sunDeg >= 117 && $sunDeg < 135)
        {
            $res = '庚金';
        } elseif ($sunDeg >= 135 && $sunDeg < 145)
        {
            $res = '戊土';
        } elseif ($sunDeg >= 145 && $sunDeg < 148)
        {
            $res = '壬水';
        } elseif ($sunDeg >= 148 && $sunDeg < 165)
        {
            $res = '庚金';
        } elseif ($sunDeg >= 165 && $sunDeg < 175)
        {
            $res = '庚金';
        } elseif ($sunDeg >= 175 && $sunDeg < 195)
        {
            $res = '辛金';
        } elseif ($sunDeg >= 195 && $sunDeg < 204)
        {
            $res = '辛金';
        } elseif ($sunDeg >= 204 && $sunDeg < 207)
        {
            $res = '丁火';
        } elseif ($sunDeg >= 207 && $sunDeg < 225)
        {
            $res = '戊土';
        } elseif ($sunDeg >= 225 && $sunDeg < 232)
        {
            $res = '戊土';
        } elseif ($sunDeg >= 232 && $sunDeg < 237)
        {
            $res = '甲木';
        } elseif ($sunDeg >= 237 && $sunDeg < 255)
        {
            $res = '壬水';
        } elseif ($sunDeg >= 255 && $sunDeg < 265)
        {
            $res = '壬水';
        } elseif ($sunDeg >= 265 && $sunDeg < 285)
        {
            $res = '癸水';
        } elseif ($sunDeg >= 285 && $sunDeg < 294)
        {
            $res = '癸水';
        } elseif ($sunDeg >= 294 && $sunDeg < 297)
        {
            $res = '辛金';
        } elseif ($sunDeg >= 297 && $sunDeg < 315)
        {
            $res = '己土';
        } elseif ($sunDeg >= 315 && $sunDeg < 322)
        {
            $res = '戊土';
        } elseif ($sunDeg >= 322 && $sunDeg < 329)
        {
            $res = '丙火';
        } elseif ($sunDeg >= 329 && $sunDeg < 345)
        {
            $res = '甲木';
        } elseif ($sunDeg >= 345 && $sunDeg < 355)
        {
            $res = '甲木';
        } elseif ($sunDeg >= 355 && $sunDeg < 360)
        {
            $res = '乙木';
        }
        return $res;
    }

    /**
     * 天干地支文字组合排序
     * @param array $zuhe
     * @return string
     */
    private function dealNameSort($zuhe = []): string
    {
        $res = '';
        if (!empty($zuhe))
        {
            $all = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸', '子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'];
            $tmp = [];
            foreach ($zuhe as $k1 => $v1)
            {
                $tmp[] = [
                    'name' => $v1,
                    'sort' => array_search($v1, $all, true),
                ];
            }
            $tmp = resort($tmp, 'sort', 'ASC');
            $res = implode('', array_column($tmp, 'name'));
        }
        return $res;
    }

    /**
     * 获取节气名称
     * @param $deg
     * @return string
     */
    public function getJieQiName($deg): string
    {
        $deg = floor($deg);
        switch ($deg)
        {
            case 0:
                $name = '春分';
                break;
            case 15:
                $name = '清明';
                break;
            case 30:
                $name = '谷雨';
                break;
            case 45:
                $name = '立夏';
                break;
            case 60:
                $name = '小满';
                break;
            case 75:
                $name = '芒种';
                break;
            case 90:
                $name = '夏至';
                break;
            case 105:
                $name = '小暑';
                break;
            case 120:
                $name = '大暑';
                break;
            case 135:
                $name = '立秋';
                break;
            case 150:
                $name = '处暑';
                break;
            case 165:
                $name = '白露';
                break;
            case 180:
                $name = '秋分';
                break;
            case 195:
                $name = '寒露';
                break;
            case 210:
                $name = '霜降';
                break;
            case 225:
                $name = '立冬';
                break;
            case 240:
                $name = '小雪';
                break;
            case 255:
                $name = '大雪';
                break;
            case 270:
                $name = '冬至';
                break;
            case 285:
                $name = '小寒';
                break;
            case 300:
                $name = '大寒';
                break;
            case 315:
                $name = '立春';
                break;
            case 330:
                $name = '雨水';
                break;
            case 345:
                $name = '惊蛰';
                break;
            default:
                $name = '';
        }
        return $name;
    }

    /**
     * 计算流月天干地支(年干取月)
     * @param string $nianGan 年干
     * @param int $sunDeg 太阳度数
     * @return array
     */
    protected function getLiuyueGanzhi($nianGan = '', $sunDeg = 0): array
    {
        $res = [];
        // 十天干
        $Heavenly_Stems = $this->param['heavenly_stems'];
        // 每15度一个节气   总共二十四节气  月令地支
        $month_branche = ['卯', '辰', '辰', '巳', '巳', '午', '午', '未', '未', '申', '申', '酉', '酉', '戌', '戌', '亥', '亥', '子', '子', '丑', '丑', '寅', '寅', '卯'];

        $temp = ['寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥', '子', '丑'];// 十二个月

        // $temp2 = ["丙","戊","庚","壬","甲","丙","戊","庚","壬","甲"];
        $temp2 = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0];

        $month_branche_num = (int)(floor($sunDeg / 15));// 向下取整

        $month_branche_str = $month_branche[$month_branche_num];// 月令地支

        $year_num = array_search($nianGan, $Heavenly_Stems, true);

        $start_num = $temp2[$year_num];

        $month_branche_num = array_search($month_branche_str, $temp);

        $newArr = array_merge($Heavenly_Stems, $Heavenly_Stems, $Heavenly_Stems);

        $s = [];

        for ($i = $start_num; $i < $start_num + 12; $i++) $s[] = $newArr[$i];

        $res[0] = $s[$month_branche_num];
        $res[1] = $month_branche_str;
        return $res;
    }

    /**
     * 根据日干时支获取时干
     * @param string $rigan 日干
     * @param string $shizhi 时辰地支
     * @return mixed
     */
    public function getShiGan($rigan = '', $shizhi = '')
    {
        // 十天干
        $tianganList = $this->param['heavenly_stems'];
        // 十二地支
        $dizhiList = $this->param['earthly_branches'];
        // $temp2 = ["甲","丙","戊","庚","壬","甲","丙","戊","庚","壬"];
        $temp2 = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8];

        $day_num = array_search($rigan, $tianganList, true);

        $start_num = $temp2[$day_num];

        $hour_branche_num = array_search($shizhi, $dizhiList, true);

        $newArr = array_merge($tianganList, $tianganList, $tianganList);

        $s = [];
        for ($i = $start_num; $i < $start_num + 12; $i++)
        {
            $s[] = $newArr[$i];
        }
        return $s[$hour_branche_num];
    }

    /**
     * 时间差转换为年月日
     * @param int $timestamp1 开始时间（时间戳）
     * @param int $timestamp2 结束时间（时间戳）
     * @param string $format 默认格式化为*年*月*日
     * @return string
     */
    protected function toTimeStr($timestamp1 = 0, int $timestamp2 = 0, $format = '%y年%m月%d天')
    {
        $date1 = date_create(date('Y-m-d', $timestamp1));
        $date2 = date_create(date('Y-m-d', $timestamp2));
        $diff = date_diff($date1, $date2);
        return $diff->format($format);
    }

    /**
     * 八字内格
     * @param array $bazi
     * @param null $yongshenState 用神状态  0=>从弱,1=>身弱,2=>身强,3=>从强
     * @param array $wangshuaiYongshen 旺衰用神
     * @return array
     */
    public function bazineige($bazi = [], $yongshenState = null, $wangshuaiYongshen = []): array
    {
        $res = [];
        $geju = $this->getStructure($bazi);
        $config_shishen = $this->param['shishen'];
        $config_canggan = $this->param['canggan'];
        // 八字中的所有天干
        $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
        // 八字中的所有地支
        $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
        $rigan = $tiangan[2];
        $tianganShishen = [];
        foreach ($tiangan as $k1 => $v1)
        {
            if ($k1 === 2) continue;
            $tianganShishen[$k1] = $config_shishen[$v1][$rigan];
        }
        $zhibenqiShishen = [];
        foreach ($dizhi as $k1 => $v1)
        {
            $zhibenqiShishen[$k1] = $config_shishen[$config_canggan[$v1][0]][$rigan];
        }
        // 计算八字中十神出现的次数
        $baziSS = array_merge($tianganShishen, $zhibenqiShishen);
        $baziSSRepeatCount = array_count_values($baziSS);
        $baziSSRepeatCount['正财'] = $baziSSRepeatCount['正财'] ?? 0;
        $baziSSRepeatCount['偏财'] = $baziSSRepeatCount['偏财'] ?? 0;
        if (mb_strpos($geju, '通变') === 0)
        {
            $cgss = '';
            // 通变相关格局，取月令本气
            // 如果月令是辰戌丑未且日干是戊己的，不取本气，取该月支在天干透出或在地支存在本气根的非本气藏干
            // 多于一个符合条件的，优先透干，优先实力强的
            if (in_array($dizhi[1], ['辰', '戌', '丑', '未'], true)
                && in_array($tiangan[2], ['戊', '己'], true))
            {
                // 获取月支非本气藏干
                $y_canggan = $config_canggan[$dizhi[1]];
                array_shift($y_canggan);
                // 取该月支在天干透出或在地支存在本气根的非本气藏干
                foreach ($y_canggan as $k1 => $v1)
                {
                    // 非本气在天干透出
                    if (in_array($v1, $tiangan, true))
                    {
                        $cgss = $config_shishen[$v1][$rigan];
                        $geju = $cgss . '格';
                        break;
                    }
                }
                if ($cgss === '')
                {
                    foreach ($dizhi as $k1 => $v1)
                    {
                        if ($k1 === 1) continue;
                        foreach ($config_canggan[$v1] as $k2 => $v2)
                        {
                            if ($k2 === 0 && in_array($v2, $y_canggan, true))
                            {
                                $cgss = $config_shishen[$v2][$rigan];
                                $geju = $cgss . '格';
                                break 2;
                            }
                        }
                    }
                }
                // 如果没有符合条件的月令非本气根，优先取月令中气
                if ($cgss === '')
                {
                    $cgss = $config_shishen[$y_canggan[0]][$rigan];
                    $geju = $cgss . '格';
                }
            } else
            {
                // 取月令本气
                $cgss = $config_shishen[$config_canggan[$dizhi[1]][0]][$rigan];
                $geju = $cgss . '格';
            }
        }

        $geju = mb_substr($geju, -3, 3);
        // 建禄格、月劫格、月刃格，同时月令是巳午且为印，转印格进行检测
        if (in_array($geju, ['建禄格', '月劫格', '月刃格'], true)
            && in_array($dizhi[1], ['巳', '午'], true)
            && in_array($zhibenqiShishen[1], ['正印', '偏印'], true))
        {
            $geju = $zhibenqiShishen[1] . '格';
        } elseif ($geju === '无主格')
        {
            // 无主格的话就从月令藏干（包括本气）中找个最旺的且不是比劫的来取格，优先本气
            $HoroscopeFortune = HoroscopeFortune::getInstance()->setHoroscopeInstance($this)->setBazi($bazi);
            $tianganPower = $HoroscopeFortune->tianganPower();// 计算十天干气力值
            $cangganWang = [];
            foreach ($config_canggan[$dizhi[1]] as $k1 => $v1)
            {
                $vShishen = $config_shishen[$v1][$rigan];
                if (!in_array($vShishen, ['比肩', '劫财'], true))
                {
                    $cangganWang[] = [
                        'gan' => $v1,
                        'score' => $tianganPower[$v1]['score'],
                        'shishen' => $vShishen,
                        'index' => $k1,
                    ];
                }
            }
            if (!empty($cangganWang))
            {
                $cangganWangResort = resort($cangganWang, 'score', 'DESC');
                $geju = $cangganWangResort[0]['shishen'] . '格';
            }
        }
        $yongshen = [];
        if ($geju === '建禄格')
        {
            /**
             * 天干有杀 建禄用杀 80
             *  格局用神取官杀，用神分官7 杀7
             */
            if (in_array('七杀', $tianganShishen, true))
            {
                $yongshen = [
                    '正官' => 7,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 0,
                    'score' => 80,
                ];
            } /**
             * 天干有官 建禄用官 100
             *  格局用神 官杀，官10杀5
             */
            elseif (in_array('正官', $tianganShishen, true))
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 1,
                    'score' => 100,
                ];
            } /**
             * 天干有财、才 建禄用财 95
             *  用神财才，天干有的10，没有的6
             */
            elseif (in_array('正财', $tianganShishen, true)
                || in_array('偏财', $tianganShishen, true))
            {
                // 天干有的10，没有的6
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 2,
                    'score' => 95,
                ];
            } /**
             * 天干有食 食神吐秀 90
             *  食神10伤官5
             */
            elseif (in_array('食神', $tianganShishen, true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 3,
                    'score' => 90,
                ];
            } /**
             * 天干有伤 伤官泄秀 80
             *  伤官7食神7
             */
            elseif (in_array('伤官', $tianganShishen, true))
            {
                $yongshen = [
                    '伤官' => 7,
                    '食神' => 7,
                ];
                $res = [
                    'code' => 4,
                    'score' => 80,
                ];
            } /**
             * 日时支（本气，其它同）有杀 建禄用杀 80（格局取法不同，基数有变化）
             *  官7杀7（格局名字定了，用神及其用神分就定了，不会随格局取法改变）
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '正官' => 7,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 0,
                    'score' => 80,
                ];
            } /**
             * 日时支有官 建禄用官 85
             */
            elseif ($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 1,
                    'score' => 85,
                ];
            } /**
             * 日时支有财才 建禄用财 80
             */
            elseif ($zhibenqiShishen[2] === '正财' || $zhibenqiShishen[3] === '正财'
                || $zhibenqiShishen[2] === '偏财' || $zhibenqiShishen[3] === '偏财')
            {
                // 天干有的10，没有的6
                $yongshen = [
                    '正财' => 6,
                    '偏财' => 6,
                ];
                $res = [
                    'code' => 2,
                    'score' => 80,
                ];
            } /**
             * 日时支有食 食神吐秀 80
             */
            elseif ($zhibenqiShishen[2] === '食神' || $zhibenqiShishen[3] === '食神')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 3,
                    'score' => 80,
                ];
            } /**
             * 日时支有伤 伤官泄秀 75
             */
            elseif ($zhibenqiShishen[2] === '伤官' || $zhibenqiShishen[3] === '伤官')
            {
                $yongshen = [
                    '食神' => 7,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 4,
                    'score' => 75,
                ];
            } /**
             * 干支都有印星 禄印随身 80
             *  官5杀5
             */
            elseif ($zhibenqiShishen[2] === '正印' || $zhibenqiShishen[3] === '正印'
                || $zhibenqiShishen[2] === '偏印' || $zhibenqiShishen[3] === '偏印')
            {
                $yongshen = [
                    '正官' => 5,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 5,
                    'score' => 80,
                ];
            } /**
             * 以上皆非 禄刃成势 70
             *  官5杀5
             */
            else
            {
                $yongshen = [
                    '正官' => 5,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 6,
                    'score' => 70,
                ];
            }
        } elseif ($geju === '正官格')
        {
            /**
             * 天干有食神与正官合 正官合食 70
             *  印5官5
             */
            if (($this->is_wuhe($tiangan[0], $tiangan[1])
                    && (($tianganShishen[0] === '食神' && $tianganShishen[1] === '正官')
                        || ($tianganShishen[1] === '食神' && $tianganShishen[0] === '正官')))
                || ($this->is_wuhe($tiangan[0], $tiangan[3])
                    && (($tianganShishen[0] === '食神' && $tianganShishen[3] === '正官')
                        || ($tianganShishen[3] === '食神' && $tianganShishen[0] === '正官')))
                || ($this->is_wuhe($tiangan[1], $tiangan[3])
                    && (($tianganShishen[1] === '食神' && $tianganShishen[3] === '正官')
                        || ($tianganShishen[3] === '食神' && $tianganShishen[1] === '正官'))))
            {
                $yongshen = [
                    '正印' => 5,
                    '正官' => 5,
                ];
                $res = [
                    'code' => 7,
                    'score' => 70,
                ];
            } /**
             * 天干有财，日干有本气根(四个地支本气有与日干相同的五行) 正官用财 100
             *  财10才10
             */
            elseif (in_array('正财', $tianganShishen, true)
                && (in_array('比肩', $zhibenqiShishen, true)
                    || in_array('劫财', $zhibenqiShishen, true)))
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 8,
                    'score' => 100,
                ];
            } /**
             * 天干有印星 正官用印 100
             *  印10枭7
             */
            elseif (in_array('正印', $tianganShishen, true)
                || in_array('偏印', $tianganShishen, true))
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 7,
                ];
                $res = [
                    'code' => 9,
                    'score' => 100,
                ];
            } /**
             * 天干有财，日干无本气根 正官用财 90
             */
            elseif (in_array('正财', $tianganShishen, true)
                && !in_array('比肩', $zhibenqiShishen, true)
                && !in_array('劫财', $zhibenqiShishen, true))
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 8,
                    'score' => 90,
                ];
            } /**
             * 天干有官有劫 正官制劫 80
             *  财7才7
             */
            elseif (in_array('正官', $tianganShishen, true)
                && in_array('劫财', $tianganShishen, true))
            {
                $yongshen = [
                    '正财' => 7,
                    '偏财' => 7,
                ];
                $res = [
                    'code' => 10,
                    'score' => 80,
                ];
            } /**
             * 地支有官受生组合，正官用财 90 地支有正官 和 正/偏财 且有地支关系 合拱
             */
            elseif (($zhibenqiShishen[0] === '正官'
                    && in_array($zhibenqiShishen[1], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[1]) || $this->is_gong($dizhi[0], $dizhi[1])))
                || ($zhibenqiShishen[0] === '正官'
                    && in_array($zhibenqiShishen[2], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[2]) || $this->is_gong($dizhi[0], $dizhi[2])))
                || ($zhibenqiShishen[0] === '正官'
                    && in_array($zhibenqiShishen[3], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[3]) || $this->is_gong($dizhi[0], $dizhi[3])))
                || ($zhibenqiShishen[1] === '正官'
                    && in_array($zhibenqiShishen[0], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[1]) || $this->is_gong($dizhi[0], $dizhi[1])))
                || ($zhibenqiShishen[1] === '正官'
                    && in_array($zhibenqiShishen[2], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[2]) || $this->is_gong($dizhi[1], $dizhi[2])))
                || ($zhibenqiShishen[1] === '正官'
                    && in_array($zhibenqiShishen[3], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[3]) || $this->is_gong($dizhi[1], $dizhi[3])))
                || ($zhibenqiShishen[2] === '正官'
                    && in_array($zhibenqiShishen[0], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[2]) || $this->is_gong($dizhi[0], $dizhi[2])))
                || ($zhibenqiShishen[2] === '正官'
                    && in_array($zhibenqiShishen[1], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[2]) || $this->is_gong($dizhi[1], $dizhi[2])))
                || ($zhibenqiShishen[2] === '正官'
                    && in_array($zhibenqiShishen[3], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[2], $dizhi[3]) || $this->is_gong($dizhi[2], $dizhi[3])))
                || ($zhibenqiShishen[3] === '正官'
                    && in_array($zhibenqiShishen[0], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[3]) || $this->is_gong($dizhi[0], $dizhi[3])))
                || ($zhibenqiShishen[3] === '正官'
                    && in_array($zhibenqiShishen[1], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[3]) || $this->is_gong($dizhi[1], $dizhi[3])))
                || ($zhibenqiShishen[3] === '正官'
                    && in_array($zhibenqiShishen[2], ['正财', '偏财'], true)
                    && ($this->is_liuhe($dizhi[2], $dizhi[3]) || $this->is_gong($dizhi[2], $dizhi[3]))))
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 8,
                    'score' => 90,
                ];
            } /**
             * 地支有印受生组合，正官用印 90 地支有正印 和 正官/七杀 且有地支关系
             */
            elseif (($zhibenqiShishen[0] === '正印'
                    && in_array($zhibenqiShishen[1], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[1]) || $this->is_gong($dizhi[0], $dizhi[1])))
                || ($zhibenqiShishen[0] === '正印'
                    && in_array($zhibenqiShishen[2], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[2]) || $this->is_gong($dizhi[0], $dizhi[2])))
                || ($zhibenqiShishen[0] === '正印'
                    && in_array($zhibenqiShishen[3], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[3]) || $this->is_gong($dizhi[0], $dizhi[3])))
                || ($zhibenqiShishen[1] === '正印'
                    && in_array($zhibenqiShishen[0], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[1]) || $this->is_gong($dizhi[0], $dizhi[1])))
                || ($zhibenqiShishen[1] === '正印'
                    && in_array($zhibenqiShishen[2], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[2]) || $this->is_gong($dizhi[1], $dizhi[2])))
                || ($zhibenqiShishen[1] === '正印'
                    && in_array($zhibenqiShishen[3], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[3]) || $this->is_gong($dizhi[1], $dizhi[3])))
                || ($zhibenqiShishen[2] === '正印'
                    && in_array($zhibenqiShishen[0], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[2]) || $this->is_gong($dizhi[0], $dizhi[2])))
                || ($zhibenqiShishen[2] === '正印'
                    && in_array($zhibenqiShishen[1], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[2]) || $this->is_gong($dizhi[1], $dizhi[2])))
                || ($zhibenqiShishen[2] === '正印'
                    && in_array($zhibenqiShishen[3], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[2], $dizhi[3]) || $this->is_gong($dizhi[2], $dizhi[3])))
                || ($zhibenqiShishen[3] === '正印'
                    && in_array($zhibenqiShishen[0], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[0], $dizhi[3]) || $this->is_gong($dizhi[0], $dizhi[3])))
                || ($zhibenqiShishen[3] === '正印'
                    && in_array($zhibenqiShishen[1], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[1], $dizhi[3]) || $this->is_gong($dizhi[1], $dizhi[3])))
                || ($zhibenqiShishen[3] === '正印'
                    && in_array($zhibenqiShishen[2], ['正官', '七杀'], true)
                    && ($this->is_liuhe($dizhi[2], $dizhi[3]) || $this->is_gong($dizhi[2], $dizhi[3]))))
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 7,
                ];
                $res = [
                    'code' => 9,
                    'score' => 90,
                ];
            } /**
             * 日时支有财，正官用财 80
             */
            elseif ($zhibenqiShishen[2] === '正财' || $zhibenqiShishen[3] === '正财')
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 8,
                    'score' => 80,
                ];
            } /**
             * 日时支有印，正官用印 85
             */
            elseif ($zhibenqiShishen[2] === '正印' || $zhibenqiShishen[3] === '正印')
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 7,
                ];
                $res = [
                    'code' => 9,
                    'score' => 85,
                ];
            } /**
             * 其它 官格待用 65
             *  同旺衰用神
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 11,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '七杀格')
        {
            /**
             * 月干、时干有印 七杀用印 100
             *  印10枭5
             */
            if ($tianganShishen[1] === '正印' || $tianganShishen[3] === '正印')
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 5,
                ];
                $res = [
                    'code' => 12,
                    'score' => 100,
                ];
            } /**
             * 月干时干有食 杀邀食制 100
             *  食10伤5
             */
            elseif ($tianganShishen[1] === '食神' || $tianganShishen[3] === '食神')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 13,
                    'score' => 100,
                ];
            } /**
             * 月干时干有伤官 杀用伤官 85（如果七杀也在天干且伤官合七杀，95）
             *  伤7食7
             */
            elseif ($tianganShishen[1] === '伤官' || $tianganShishen[3] === '伤官')
            {
                $yongshen = [
                    '食神' => 7,
                    '伤官' => 7,
                ];
                if (($tianganShishen[1] === '伤官'
                        && (($tianganShishen[0] === '七杀'
                                && $this->is_wuhe($tiangan[0], $tiangan[1]))
                            || ($tianganShishen[3] === '七杀'
                                && $this->is_wuhe($tiangan[3], $tiangan[1]))))
                    || ($tianganShishen[3] === '伤官'
                        && (($tianganShishen[0] === '七杀'
                                && $this->is_wuhe($tiangan[0], $tiangan[3]))
                            || ($tianganShishen[1] === '七杀'
                                && $this->is_wuhe($tiangan[3], $tiangan[1])))))
                {
                    $res = [
                        'code' => 14,
                        'score' => 95,
                    ];
                } else
                {
                    $res = [
                        'code' => 14,
                        'score' => 85,
                    ];
                }
            } /**
             * 月干时干有劫财 杀用劫刃 85（如果七杀也在天干且劫财合七杀，95）
             *  劫7比5
             */
            elseif ($tianganShishen[1] === '劫财' || $tianganShishen[3] === '劫财')
            {
                $yongshen = [
                    '劫财' => 7,
                    '比肩' => 5,
                ];
                if (($tianganShishen[1] === '劫财'
                        && (($tianganShishen[0] === '七杀'
                                && $this->is_wuhe($tiangan[0], $tiangan[1]))
                            || ($tianganShishen[3] === '七杀'
                                && $this->is_wuhe($tiangan[3], $tiangan[1]))))
                    || ($tianganShishen[3] === '劫财'
                        && (($tianganShishen[0] === '七杀'
                                && $this->is_wuhe($tiangan[0], $tiangan[3]))
                            || ($tianganShishen[1] === '七杀'
                                && $this->is_wuhe($tiangan[3], $tiangan[1])))))
                {
                    $res = [
                        'code' => 15,
                        'score' => 95,
                    ];
                } else
                {
                    $res = [
                        'code' => 15,
                        'score' => 85,
                    ];
                }
            } /**
             * 日支有印、食、伤、劫 依次检测取格如上，基数 90，90，80,80
             */
            elseif ($zhibenqiShishen[2] === '正印')
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 5,
                ];
                $res = [
                    'code' => 12,
                    'score' => 90,
                ];
            } elseif ($zhibenqiShishen[2] === '食神')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 13,
                    'score' => 90,
                ];
            } elseif ($zhibenqiShishen[2] === '伤官')
            {
                $yongshen = [
                    '食神' => 7,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 14,
                    'score' => 80,
                ];
            } elseif ($zhibenqiShishen[2] === '劫财')
            {
                $yongshen = [
                    '劫财' => 7,
                    '比肩' => 5,
                ];
                $res = [
                    'code' => 15,
                    'score' => 80,
                ];
            } /**
             * 年干或时支有印、食、伤、劫 依次检测取格如上，基数85,85,75,75
             */
            elseif ($tianganShishen[0] === '正印' || $zhibenqiShishen[3] === '正印')
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 5,
                ];
                $res = [
                    'code' => 12,
                    'score' => 85,
                ];
            } elseif ($tianganShishen[0] === '食神' || $zhibenqiShishen[3] === '食神')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 13,
                    'score' => 85,
                ];
            } elseif ($tianganShishen[0] === '伤官' || $zhibenqiShishen[3] === '伤官')
            {
                $yongshen = [
                    '食神' => 7,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 14,
                    'score' => 75,
                ];
            } elseif ($tianganShishen[0] === '劫财' || $zhibenqiShishen[3] === '劫财')
            {
                $yongshen = [
                    '劫财' => 7,
                    '比肩' => 5,
                ];
                $res = [
                    'code' => 15,
                    'score' => 75,
                ];
            } /**
             * 以上皆无 杀格待用 65
             *  用神同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 16,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '正财格')
        {
            /**
             * 天干同时有杀印或食杀或伤杀或劫杀，或天干有七杀同时日时支有比劫本气 财逢七杀 90
             *  天干有印、食、伤、劫都取为用神10，如没有，取劫7比7
             */
            if (in_array('七杀', $tianganShishen, true)
                && (in_array('正印', $tianganShishen, true)
                    || in_array('食神', $tianganShishen, true)
                    || in_array('伤官', $tianganShishen, true)
                    || in_array('劫财', $tianganShishen, true)
                    || in_array($zhibenqiShishen[2], ['比肩', '劫财'], true)
                    || in_array($zhibenqiShishen[3], ['比肩', '劫财'], true)
                ))
            {
                if (in_array('正印', $tianganShishen, true))
                {
                    $yongshen['正印'] = 10;
                }
                if (in_array('食神', $tianganShishen, true))
                {
                    $yongshen['食神'] = 10;
                }
                if (in_array('伤官', $tianganShishen, true))
                {
                    $yongshen['伤官'] = 10;
                }
                if (in_array('劫财', $tianganShishen, true))
                {
                    $yongshen['劫财'] = 10;
                }
                if (empty($yongshen))
                {
                    $yongshen = [
                        '劫财' => 7,
                        '比肩' => 7,
                    ];
                }
                $res = [
                    'code' => 17,
                    'score' => 90,
                ];
            } /**
             * 天干+地支本气有财星四个以上，时干或日时支本气有比劫 财用比劫 85
             *  比肩8劫财8
             */
            elseif ($baziSSRepeatCount['正财'] + $baziSSRepeatCount['偏财'] >= 4
                && (in_array($tianganShishen[3], ['比肩', '劫财'], true)
                    || in_array($zhibenqiShishen[2], ['比肩', '劫财'], true)
                    || in_array($zhibenqiShishen[3], ['比肩', '劫财'], true)))
            {
                $yongshen = [
                    '劫财' => 8,
                    '比肩' => 8,
                ];
                $res = [
                    'code' => 18,
                    'score' => 85,
                ];
            } /**
             * 月干、时干有官、食伤 财官相生、财喜食伤 100、100
             *  官10杀5、食10伤7
             */
            elseif ($tianganShishen[1] === '正官' || $tianganShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 19,
                    'score' => 100,
                ];
            } elseif (in_array($tianganShishen[1], ['食神', '伤官'], true)
                || in_array($tianganShishen[3], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 20,
                    'score' => 100,
                ];
            } /**
             * 年干有官 财官相生 95
             */
            elseif ($tianganShishen[0] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 19,
                    'score' => 95,
                ];
            } /**
             * 月干、时干有印枭 财星配印 95
             *  身弱印10枭7，身旺官7杀5
             */
            elseif (in_array($tianganShishen[1], ['正印', '偏印'], true)
                || in_array($tianganShishen[3], ['正印', '偏印'], true))
            {
                // 身弱印10枭7，身旺官7杀5 从旺与身弱同，从弱与身旺同
                // 0=>从弱,1=>身弱,2=>身强,3=>从强
                if ($yongshenState === 1 || $yongshenState === 3)
                {
                    $yongshen = [
                        '正印' => 10,
                        '偏印' => 7,
                    ];
                } else
                {
                    $yongshen = [
                        '正官' => 7,
                        '七杀' => 5,
                    ];
                }
                $res = [
                    'code' => 21,
                    'score' => 95,
                ];
            } /**
             * 年干有食伤 财喜食伤 90
             */
            elseif (in_array($tianganShishen[0], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 20,
                    'score' => 90,
                ];
            } /**
             * 年干有印枭 财星配印 85
             */
            elseif (in_array($tianganShishen[0], ['正印', '偏印'], true))
            {
                // 身弱印10枭7，身旺官7杀5 从旺与身弱同，从弱与身旺同
                // 0=>从弱,1=>身弱,2=>身强,3=>从强
                if ($yongshenState === 1 || $yongshenState === 3)
                {
                    $yongshen = [
                        '正印' => 10,
                        '偏印' => 7,
                    ];
                } else
                {
                    $yongshen = [
                        '正官' => 7,
                        '七杀' => 5,
                    ];
                }
                $res = [
                    'code' => 21,
                    'score' => 85,
                ];
            } /**
             * 日支时支有官、食伤 财官相生、财喜食伤 80、80
             */
            elseif ($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 19,
                    'score' => 80,
                ];
            } elseif (in_array($zhibenqiShishen[2], ['食神', '伤官'], true)
                || in_array($zhibenqiShishen[3], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 20,
                    'score' => 80,
                ];
            } /**
             * 日支时支有杀，身旺 财逢七杀 80
             */
            elseif (($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
                && $this->is_shenwang(false))
            {
                if (in_array('正印', $tianganShishen, true))
                {
                    $yongshen['正印'] = 10;
                }
                if (in_array('食神', $tianganShishen, true))
                {
                    $yongshen['食神'] = 10;
                }
                if (in_array('伤官', $tianganShishen, true))
                {
                    $yongshen['伤官'] = 10;
                }
                if (in_array('劫财', $tianganShishen, true))
                {
                    $yongshen['劫财'] = 10;
                }
                if (empty($yongshen))
                {
                    $yongshen = [
                        '劫财' => 7,
                        '比肩' => 7,
                    ];
                }
                $res = [
                    'code' => 17,
                    'score' => 80,
                ];
            } /**
             * 其它 财格待用 65
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 22,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '偏财格')
        {
            /**
             * 天干同时有杀印或食杀或伤杀或劫杀，或天干有七杀同时日时支有比劫本气 财逢七杀 90
             *  天干有印、食、伤、劫都取为用神10，如没有，取劫7比7
             */
            if (in_array('七杀', $tianganShishen, true)
                && (in_array('正印', $tianganShishen, true)
                    || in_array('食神', $tianganShishen, true)
                    || in_array('伤官', $tianganShishen, true)
                    || in_array('劫财', $tianganShishen, true)
                    || in_array($zhibenqiShishen[2], ['比肩', '劫财'], true)
                    || in_array($zhibenqiShishen[3], ['比肩', '劫财'], true)
                ))
            {
                if (in_array('正印', $tianganShishen, true))
                {
                    $yongshen['正印'] = 10;
                }
                if (in_array('食神', $tianganShishen, true))
                {
                    $yongshen['食神'] = 10;
                }
                if (in_array('伤官', $tianganShishen, true))
                {
                    $yongshen['伤官'] = 10;
                }
                if (in_array('劫财', $tianganShishen, true))
                {
                    $yongshen['劫财'] = 10;
                }
                if (empty($yongshen))
                {
                    $yongshen = [
                        '劫财' => 7,
                        '比肩' => 7,
                    ];
                }
                $res = [
                    'code' => 17,
                    'score' => 90,
                ];
            } /**
             * 天干+地支本气有财星四个以上，时干或日时支本气有比劫 财用比劫 85
             *  比肩8劫财8
             */
            elseif ($baziSSRepeatCount['正财'] + $baziSSRepeatCount['偏财'] >= 4
                && (in_array($tianganShishen[3], ['比肩', '劫财'], true)
                    || in_array($zhibenqiShishen[2], ['比肩', '劫财'], true)
                    || in_array($zhibenqiShishen[3], ['比肩', '劫财'], true)))
            {
                $yongshen = [
                    '劫财' => 8,
                    '比肩' => 8,
                ];
                $res = [
                    'code' => 18,
                    'score' => 85,
                ];
            } /**
             * 月干、时干有官、食伤 财官相生、财喜食伤 100、100
             *  官10杀5、食10伤7
             */
            elseif ($tianganShishen[1] === '正官' || $tianganShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 19,
                    'score' => 100,
                ];
            } elseif (in_array($tianganShishen[1], ['食神', '伤官'], true)
                || in_array($tianganShishen[3], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 20,
                    'score' => 100,
                ];
            } /**
             * 年干有官 财官相生 95
             */
            elseif ($tianganShishen[0] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 19,
                    'score' => 95,
                ];
            } /**
             * 月干、时干有印枭 财星配印 95
             *  身弱印10枭7，身旺官7杀5
             */
            elseif (in_array($tianganShishen[1], ['正印', '偏印'], true)
                || in_array($tianganShishen[3], ['正印', '偏印'], true))
            {
                // 身弱印10枭7，身旺官7杀5 从旺与身弱同，从弱与身旺同
                // 0=>从弱,1=>身弱,2=>身强,3=>从强
                if ($yongshenState === 1 || $yongshenState === 3)
                {
                    $yongshen = [
                        '正印' => 10,
                        '偏印' => 7,
                    ];
                } else
                {
                    $yongshen = [
                        '正官' => 7,
                        '七杀' => 5,
                    ];
                }
                $res = [
                    'code' => 21,
                    'score' => 95,
                ];
            } /**
             * 年干有食伤 财喜食伤 90
             */
            elseif (in_array($tianganShishen[0], ['食神', '伤官'], true))
            {
                $res = [
                    'code' => 20,
                    'score' => 90,
                ];
            } /**
             * 年干有印枭 财星配印 85
             */
            elseif (in_array($tianganShishen[0], ['正印', '偏印'], true))
            {
                // 身弱印10枭7，身旺官7杀5 从旺与身弱同，从弱与身旺同
                // 0=>从弱,1=>身弱,2=>身强,3=>从强
                if ($yongshenState === 1 || $yongshenState === 3)
                {
                    $yongshen = [
                        '正印' => 10,
                        '偏印' => 7,
                    ];
                } else
                {
                    $yongshen = [
                        '正官' => 7,
                        '七杀' => 5,
                    ];
                }
                $res = [
                    'code' => 21,
                    'score' => 85,
                ];
            } /**
             * 日支时支有官、食伤 财官相生、财喜食伤 80、80
             */
            elseif ($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 19,
                    'score' => 80,
                ];
            } elseif (in_array($zhibenqiShishen[2], ['食神', '伤官'], true)
                || in_array($zhibenqiShishen[3], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 20,
                    'score' => 80,
                ];
            } /**
             * 日支时支有杀，身旺 财逢七杀 80
             */
            elseif (($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
                && $this->is_shenwang(false))
            {
                if (in_array('正印', $tianganShishen, true))
                {
                    $yongshen['正印'] = 10;
                }
                if (in_array('食神', $tianganShishen, true))
                {
                    $yongshen['食神'] = 10;
                }
                if (in_array('伤官', $tianganShishen, true))
                {
                    $yongshen['伤官'] = 10;
                }
                if (in_array('劫财', $tianganShishen, true))
                {
                    $yongshen['劫财'] = 10;
                }
                if (empty($yongshen))
                {
                    $yongshen = [
                        '劫财' => 7,
                        '比肩' => 7,
                    ];
                }
                $res = [
                    'code' => 17,
                    'score' => 80,
                ];
            } /**
             * 其它 财格待用 65
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 22,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '食神格')
        {
            /**
             * 天干有七杀或地支有组合食杀 食神制杀 100
             *  食10伤5
             */
            if (in_array('七杀', $tianganShishen, true)
                || (in_array('七杀', $zhibenqiShishen, true)
                    && in_array('食神', $zhibenqiShishen, true)))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 23,
                    'score' => 100,
                ];
            } /**
             * 天干有财才 食神生财 100
             *  财10才10
             */
            elseif (in_array('正财', $tianganShishen, true)
                || in_array('偏财', $tianganShishen, true))
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 24,
                    'score' => 100,
                ];
            } /**
             * 天干有正印 食神配印 95（如干或支本气有偏印，80）
             *  印7
             */
            elseif (in_array('正印', $tianganShishen, true))
            {
                $yongshen = [
                    '正印' => 7,
                ];
                if (in_array('偏印', $tianganShishen, true)
                    || in_array('偏印', $zhibenqiShishen, true))
                {
                    $res = [
                        'code' => 25,
                        'score' => 80,
                    ];
                } else
                {
                    $res = [
                        'code' => 25,
                        'score' => 95,
                    ];
                }
            } /**
             * 干或支有比劫，天干有食神 食神吐秀 95（如天干有偏印，80）
             * 食神10伤官5
             */
            elseif (in_array('食神', $tianganShishen, true)
                && (
                    in_array('比肩', $tianganShishen, true)
                    || in_array('劫财', $tianganShishen, true)
                    || in_array('比肩', $zhibenqiShishen, true)
                    || in_array('劫财', $zhibenqiShishen, true)))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                if (in_array('偏印', $tianganShishen, true))
                {
                    $res = [
                        'code' => 26,
                        'score' => 80,
                    ];
                } else
                {
                    $res = [
                        'code' => 26,
                        'score' => 95,
                    ];
                }
            } /**
             * 日时支有七杀 食神制杀 85
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 23,
                    'score' => 85,
                ];
            } /**
             * 日时支有财才 食神生财 85
             *  财10才10
             */
            elseif ($zhibenqiShishen[2] === '正财' || $zhibenqiShishen[3] === '正财'
                || $zhibenqiShishen[2] === '偏财' || $zhibenqiShishen[3] === '偏财')
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 24,
                    'score' => 85,
                ];
            } /**
             * 其它 食格待用 65
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 27,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '伤官格')
        {
            /**
             * 伤官格，依次检测
             * 天干有七杀或地支组合有伤杀 伤官驾杀 100
             *  伤7食7
             */
            if (in_array('七杀', $tianganShishen, true)
                || (in_array('七杀', $zhibenqiShishen, true)
                    && in_array('伤官', $zhibenqiShishen, true)))
            {
                $yongshen = [
                    '伤官' => 7,
                    '食神' => 7,
                ];
                $res = [
                    'code' => 28,
                    'score' => 100,
                ];
            } /**
             * 天干有印枭 伤官配印 100
             *  印10枭9
             */
            elseif (in_array('正印', $tianganShishen, true)
                || in_array('偏印', $tianganShishen, true))
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 7,
                ];
                $res = [
                    'code' => 29,
                    'score' => 100,
                ];
            } /**
             * 天干有财才 伤官生财 100
             *  财7才7
             */
            elseif (in_array('正财', $tianganShishen, true)
                || in_array('偏财', $tianganShishen, true))
            {
                $yongshen = [
                    '正财' => 7,
                    '偏财' => 7,
                ];
                $res = [
                    'code' => 30,
                    'score' => 100,
                ];
            } /**
             * 干或支有比劫，天干有伤官无正官 伤官泄秀 90
             *  伤官7食神7
             */
            elseif (in_array('伤官', $tianganShishen, true)
                && !in_array('正官', $tianganShishen, true)
                && (in_array('比肩', $tianganShishen, true)
                    || in_array('劫财', $tianganShishen, true)
                    || in_array('比肩', $zhibenqiShishen, true)
                    || in_array('劫财', $zhibenqiShishen, true)))
            {
                $yongshen = [
                    '伤官' => 7,
                    '食神' => 7,
                ];
                $res = [
                    'code' => 31,
                    'score' => 90,
                ];
            } /**
             * 日时支有印枭 伤官配印 90
             *  印10枭9
             */
            elseif (in_array($zhibenqiShishen[2], ['正印', '偏印'], true)
                || in_array($zhibenqiShishen[3], ['正印', '偏印'], true))
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 9,
                ];
                $res = [
                    'code' => 29,
                    'score' => 90,
                ];
            } /**
             * 日时支有七杀 伤官驾杀 85
             *  伤7食7
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '伤官' => 7,
                    '食神' => 7,
                ];
                $res = [
                    'code' => 28,
                    'score' => 90,
                ];
            } /**
             * 日时支有财才 伤官生财 85
             * 财7才7
             */
            elseif (in_array($zhibenqiShishen[2], ['正财', '偏财'], true)
                || in_array($zhibenqiShishen[3], ['正财', '偏财'], true))
            {
                $yongshen = [
                    '正财' => 7,
                    '偏财' => 7,
                ];
                $res = [
                    'code' => 30,
                    'score' => 85,
                ];
            } /**
             * 其它 伤格待用 65
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 32,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '正印格')
        {
            /**
             * 正印格，依次检测
             * 天干有杀 印格用杀 100
             *  杀10官9
             */
            if (in_array('七杀', $tianganShishen, true))
            {
                $yongshen = [
                    '七杀' => 10,
                    '正官' => 9,
                ];
                $res = [
                    'code' => 33,
                    'score' => 100,
                ];
            } /**
             * 天干有官不见伤官 印格用官 100
             *  官10杀7
             */
            elseif (in_array('正官', $tianganShishen, true)
                && !in_array('伤官', $tianganShishen, true))
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 34,
                    'score' => 100,
                ];
            } /**
             * 天干或支本气有财，天干有比劫 印用比劫 90
             *  比5劫5
             */
            elseif ((in_array('正财', $tianganShishen, true)
                    || in_array('正财', $zhibenqiShishen, true))
                && (in_array('比肩', $tianganShishen, true)
                    || in_array('劫财', $tianganShishen, true)))
            {
                $yongshen = [
                    '比肩' => 5,
                    '劫财' => 5,
                ];
                $res = [
                    'code' => 35,
                    'score' => 90,
                ];
            } /**
             * 天干有食伤，有伤时不见官 印用食伤 90
             *  食10伤7
             */
            elseif (in_array('食神', $tianganShishen, true)
                || (in_array('伤官', $tianganShishen, true)
                    && !in_array('正官', $tianganShishen, true)))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 36,
                    'score' => 90,
                ];
            } /**
             * 日时支有食伤 印用食伤 80
             *  食10伤7
             */
            elseif (in_array($zhibenqiShishen[2], ['食神', '伤官'], true)
                || in_array($zhibenqiShishen[3], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 36,
                    'score' => 80,
                ];
            } /**
             * 日时支有杀 印格用杀 85
             *  杀10官9
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '七杀' => 10,
                    '正官' => 9,
                ];
                $res = [
                    'code' => 33,
                    'score' => 80,
                ];
            } /**
             * 日时支有官 印格用官 85
             *  官10杀7
             */
            elseif ($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 34,
                    'score' => 85,
                ];
            } /**
             * 其它 印格待用 65
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 37,
                    'score' => 65,
                ];
            }
        } elseif ($geju === '偏印格')
        {
            /**
             * 正印格，依次检测
             * 天干有杀 印格用杀 95
             *  杀10官9
             */
            if (in_array('七杀', $tianganShishen, true))
            {
                $yongshen = [
                    '七杀' => 10,
                    '正官' => 9,
                ];
                $res = [
                    'code' => 33,
                    'score' => 95,
                ];
            } /**
             * 天干有官不见伤官 印格用官 95
             *  官10杀7
             */
            elseif (in_array('正官', $tianganShishen, true)
                && !in_array('伤官', $tianganShishen, true))
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 34,
                    'score' => 95,
                ];
            } /**
             * 天干有财才，或地支有财枭（才枭）组合 印格用财 100
             *  才10财7
             */
            elseif ((in_array('正财', $tianganShishen, true)
                    || in_array('偏财', $tianganShishen, true))
                || (in_array('偏印', $zhibenqiShishen, true)
                    && (in_array('正财', $zhibenqiShishen, true)
                        || in_array('偏财', $zhibenqiShishen, true))))
            {
                $yongshen = [
                    '偏财' => 10,
                    '正财' => 7,
                ];
                $res = [
                    'code' => 38,
                    'score' => 100,
                ];
            } /**
             * 天干有食伤，有伤时不见官 印用食伤 85
             *  食10伤7
             */
            elseif (in_array('食神', $tianganShishen, true)
                || (in_array('伤官', $tianganShishen, true)
                    && !in_array('正官', $tianganShishen, true)))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 36,
                    'score' => 85,
                ];
            } /**
             * 日时支有财才 印格用财 90
             *  才10财7
             */
            elseif (in_array($zhibenqiShishen[2], ['正财', '偏印'], true)
                || in_array($zhibenqiShishen[3], ['正财', '偏印'], true))
            {
                $yongshen = [
                    '偏财' => 10,
                    '正财' => 7,
                ];
                $res = [
                    'code' => 38,
                    'score' => 90,
                ];
            } /**
             * 日时支有食伤 印用食伤 75
             *  食10伤7
             */
            elseif (in_array($zhibenqiShishen[2], ['食神', '伤官'], true)
                || in_array($zhibenqiShishen[3], ['食神', '伤官'], true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 36,
                    'score' => 75,
                ];
            } /**
             * 日时支有杀 印格用杀 80
             *  杀10官9
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '七杀' => 10,
                    '正官' => 9,
                ];
                $res = [
                    'code' => 33,
                    'score' => 80,
                ];
            } /**
             * 日时支有官 印格用官 80
             *  官10杀7
             */
            elseif ($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 34,
                    'score' => 80,
                ];
            } /**
             * 其它 印格待用 60
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 37,
                    'score' => 60,
                ];
            }
        } elseif ($geju === '月劫格')
        {
            /**
             * 天干有杀 月劫用杀 80
             *  格局用神取官杀，用神分官7 杀7
             */
            if (in_array('七杀', $tianganShishen, true))
            {
                $yongshen = [
                    '正官' => 7,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 39,
                    'score' => 80,
                ];
            } /**
             * 天干有官 月劫用官 100
             *  格局用神 官杀，官10杀5
             */
            elseif (in_array('正官', $tianganShishen, true))
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 40,
                    'score' => 100,
                ];
            } /**
             * 天干有财、才 月劫用财 95
             *  用神财才，天干有的10，没有的6
             */
            elseif (in_array('正财', $tianganShishen, true)
                || in_array('偏财', $tianganShishen, true))
            {
                $yongshen = [
                    '正财' => 10,
                    '偏财' => 10,
                ];
                $res = [
                    'code' => 41,
                    'score' => 95,
                ];
            } /**
             * 天干有食 食神吐秀 90
             *  食神10伤官5
             */
            elseif (in_array('食神', $tianganShishen, true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 3,
                    'score' => 90,
                ];
            } /**
             * 天干有伤 伤官泄秀 80
             *  伤官7食神7
             */
            elseif (in_array('伤官', $tianganShishen, true))
            {
                $yongshen = [
                    '伤官' => 7,
                    '食神' => 7,
                ];
                $res = [
                    'code' => 4,
                    'score' => 80,
                ];
            } /**
             * 日时支（本气，其它同）有杀 月劫用杀 80（格局取法不同，基数有变化）
             *  官7杀7（格局名字定了，用神及其用神分就定了，不会随格局取法改变）
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '正官' => 7,
                    '七杀' => 7,
                ];
                $res = [
                    'code' => 39,
                    'score' => 80,
                ];
            } /**
             * 日时支有官 月劫用官 85
             *  官10杀5
             */
            elseif ($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 40,
                    'score' => 85,
                ];
            } /**
             * 日时支有财才 月劫用财 80
             *  用神财才，天干有的10，没有的6
             */
            elseif ($zhibenqiShishen[2] === '正财' || $zhibenqiShishen[3] === '正财'
                || $zhibenqiShishen[2] === '偏财' || $zhibenqiShishen[3] === '偏财')
            {
                $yongshen = [
                    '正财' => 6,
                    '偏财' => 6,
                ];
                $res = [
                    'code' => 41,
                    'score' => 80,
                ];
            } /**
             * 日时支有食 食神吐秀 80
             *  食神10伤官5
             */
            elseif ($zhibenqiShishen[2] === '食神' || $zhibenqiShishen[3] === '食神')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 3,
                    'score' => 80,
                ];
            } /**
             * 日时支有伤 伤官泄秀 75
             *  伤官7食神7
             */
            elseif ($zhibenqiShishen[2] === '伤官' || $zhibenqiShishen[3] === '伤官')
            {
                $yongshen = [
                    '伤官' => 7,
                    '食神' => 7,
                ];
                $res = [
                    'code' => 4,
                    'score' => 75,
                ];
            } /**
             * 以上皆非 禄刃成势 70
             *  官5杀5
             */
            else
            {
                $yongshen = [
                    '正官' => 5,
                    '七杀' => 5,
                ];
                $res = [
                    'code' => 6,
                    'score' => 70,
                ];
            }
        } elseif ($geju === '月刃格')
        {
            /**
             * 天干有七杀或地支有杀与月支合 羊刃驾杀 100
             *  杀10官9
             */
            if (in_array('七杀', $tianganShishen, true)
                || ($zhibenqiShishen[0] === '七杀'
                    && ($this->is_liuhe($dizhi[0], $dizhi[1])
                        || $this->is_anhe($dizhi[0], $dizhi[1])))
                || ($zhibenqiShishen[2] === '七杀'
                    && ($this->is_liuhe($dizhi[2], $dizhi[1])
                        || $this->is_anhe($dizhi[2], $dizhi[1])))
                || ($zhibenqiShishen[3] === '七杀'
                    && ($this->is_liuhe($dizhi[3], $dizhi[1])
                        || $this->is_anhe($dizhi[3], $dizhi[1]))))
            {
                $yongshen = [
                    '七杀' => 10,
                    '正官' => 9,
                ];
                $res = [
                    'code' => 42,
                    'score' => 100,
                ];
            } /**
             * 天干有官无伤，或有官有伤但伤在年干，或有官有伤有印枭 羊刃用官 95
             *  官10杀10
             */
            elseif (
                (in_array('正官', $tianganShishen, true)
                    && (!in_array('伤官', $tianganShishen, true)
                        || $tianganShishen[0] === '伤官'))
                || (in_array('正官', $tianganShishen, true)
                    && in_array('伤官', $tianganShishen, true)
                    && (in_array('正印', $tianganShishen, true)
                        || in_array('偏印', $tianganShishen, true))))
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 10,
                ];
                $res = [
                    'code' => 43,
                    'score' => 95,
                ];
            } /**
             * 天干有财有食伤，或干支本气财有三位以上 羊刃用财 90
             *  食10伤7
             */
            elseif ($baziSSRepeatCount['正财'] >= 3
                || (in_array('正财', $tianganShishen, true)
                    || (in_array('食神', $tianganShishen, true)
                        || in_array('伤官', $tianganShishen, true))))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 7,
                ];
                $res = [
                    'code' => 44,
                    'score' => 90,
                ];
            } /**
             * 天干有食神 食神吐秀 85
             *  食神10伤官5
             */
            elseif (in_array('食神', $tianganShishen, true))
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 3,
                    'score' => 85,
                ];
            } /**
             * 天干有伤官无印枭 羊刃伤官 70
             *  杀10印7
             */
            elseif (in_array('伤官', $tianganShishen, true)
                && !in_array('正印', $tianganShishen, true)
                && !in_array('偏印', $tianganShishen, true))
            {
                $yongshen = [
                    '七杀' => 10,
                    '正印' => 7,
                ];
                $res = [
                    'code' => 45,
                    'score' => 70,
                ];
            } /**
             * 天干有伤官有印枭 伤官配印 80
             *  印10枭9
             */
            elseif (in_array('伤官', $tianganShishen, true)
                && (in_array('正印', $tianganShishen, true)
                    || in_array('偏印', $tianganShishen, true)))
            {
                $yongshen = [
                    '正印' => 10,
                    '偏印' => 9,
                ];
                $res = [
                    'code' => 29,
                    'score' => 80,
                ];
            } /**
             * 日时支有七杀 羊刃驾杀 85
             *  杀10官9
             */
            elseif ($zhibenqiShishen[2] === '七杀' || $zhibenqiShishen[3] === '七杀')
            {
                $yongshen = [
                    '七杀' => 10,
                    '正官' => 9,
                ];
                $res = [
                    'code' => 42,
                    'score' => 85,
                ];
            } /**
             * 日时支有官无伤 羊刃用官 85
             *  官10杀10
             */
            elseif (($zhibenqiShishen[2] === '正官' || $zhibenqiShishen[3] === '正官')
                && !$zhibenqiShishen[2] === '伤官' && !$zhibenqiShishen[3] === '伤官')
            {
                $yongshen = [
                    '正官' => 10,
                    '七杀' => 10,
                ];
                $res = [
                    'code' => 43,
                    'score' => 85,
                ];
            } /**
             * 日时支有食神无枭 食神吐秀 80
             *  食神10伤官5
             */
            elseif (($zhibenqiShishen[2] === '食神' || $zhibenqiShishen[3] === '食神')
                && !$zhibenqiShishen[2] === '偏印' && !$zhibenqiShishen[3] === '偏印')
            {
                $yongshen = [
                    '食神' => 10,
                    '伤官' => 5,
                ];
                $res = [
                    'code' => 3,
                    'score' => 80,
                ];
            } /**
             * 其它 月刃待用 65
             *  同旺衰
             */
            else
            {
                // 同旺衰用神 需要特殊处理
                $yongshen = $wangshuaiYongshen;
                $res = [
                    'code' => 46,
                    'score' => 65,
                ];
            }
        }
        if ($yongshenState !== null)
        {
            $res['geju'] = $geju;
            $res['yongshen'] = $yongshen;
        }
        return $res;
    }

    /**
     * 格局判定
     *  格局损益部分得分减半
     * @param array $bazi
     * @return array
     */
    public function gejupanding($bazi = []): array
    {
        $res = ['waige' => [], 'neige' => [], 'zhengti' => []];
        $waige = $this->baziwaige($bazi);
        $neige = $this->bazineige($bazi);
        $waigeTotalScore = 0;
        if (!empty($waige))
        {
            $waigeConfig = config('bazi.waige');
            // 外格可能有多个
            foreach ($waige as $k1 => $v1)
            {
                $waigeTotalScore += $waigeConfig[$v1]['score'];
                /**
                 * 外格
                 *  20 帝王之格，如龙入海
                 *  16 富贵之格，如虎添翼
                 *  12 才华之格，成就卓越
                 *  8 奋发之格，尽展所能
                 */
                if ($waigeConfig[$v1]['score'] >= 20)
                {
                    $tag_list = '帝王之格，如龙入海';
                } elseif ($waigeConfig[$v1]['score'] >= 16)
                {
                    $tag_list = '富贵之格，如虎添翼';
                } elseif ($waigeConfig[$v1]['score'] >= 12)
                {
                    $tag_list = '才华之格，成就卓越';
                } else
                {
                    $tag_list = '奋发之格，尽展所能';
                }
                $res['waige'][] = [
                    'title' => $waigeConfig[$v1]['name'],
                    'content' => $waigeConfig[$v1]['text'],
                    'score1' => $waigeConfig[$v1]['score'],
                    'score2' => 20,
                    'tag_list' => $tag_list,
                ];
            }
        }
        /**
         * 内格分数计算
         * 步骤，先定主格，再定副格，每个格局给出一个基础格局分（格局基数），在这个基础上减去【格局损益】部分所得的总分就是格局得分
         * 格局损益（数值待实验）
         * 凶神杀伤枭劫
         *   某凶神重复出现（干或支本气算1次，非本气的库藏气算0.5次）
         *      天干出现 减分=（次数-1）*凶神天干指数
         *      地支出现 减分=（次数-0.5）*凶神地支指数
         *      天干指数=格局基数*8%
         *      地支指数=格局基数*12%
         *   吉神受克
         *      八字中出现吉神受克组合（干对干、支对支、同柱干支）
         *          受克基数=格局基数*10%
         *          吉神受克减分=受克基数*施克十神旺度/受克十神旺度（气力）
         *          如果受克吉神不只一个，累加
         * 刑冲破害
         *   关系指数 冲1，刑0.7，害0.7，破0.5
         *   减分=关系指数*（3-距离）*格局基数*10%
         * 五行极端
         *   某五行过旺，且日时支（本气）、时干不克该五行
         *   减分=格局基数*9%
         */
        $neigeTotalScore = 0;
        if (!empty($neige))
        {
            $neigeTotalScore = $neige['score'];
            // 八字中的所有天干
            $tiangan = [$bazi[1], $bazi[3], $bazi[5], $bazi[7]];
            // 八字中的所有地支
            $dizhi = [$bazi[2], $bazi[4], $bazi[6], $bazi[8]];
            $rigan = $tiangan[2];
            // 内格只有1个
            $tianganXiongshenNum = 0;
            foreach ($tiangan as $k1 => $v1)
            {
                if ($k1 === 2) continue;
                if (in_array($this->param['shishen'][$v1][$tiangan[2]], ['七杀', '伤官', '偏印', '劫财'], true))
                {
                    $tianganXiongshenNum++;
                }
            }
            $dizhiXiongshenNum = 0;
            foreach ($dizhi as $k1 => $v1)
            {
                foreach ($this->param['canggan'][$v1] as $k2 => $v2)
                {
                    if (in_array($this->param['shishen'][$v2][$tiangan[2]], ['七杀', '伤官', '偏印', '劫财'], true))
                    {
                        if ($k2 === 0) $dizhiXiongshenNum++;
                        else $dizhiXiongshenNum += 0.5;
                    }
                }
            }
            $tainganZhishu = $neige['score'] * 0.08;
            $dizhiZhishu = $neige['score'] * 0.12;
            $neigeTotalScore -= $tainganZhishu * ($tianganXiongshenNum - 1) * 0.5;
            $neigeTotalScore -= $dizhiZhishu * ($dizhiXiongshenNum - 0.5) * 0.5;
            $HoroscopeFortune = HoroscopeFortune::getInstance()->setHoroscopeInstance($this)->setBazi($bazi);
            $tianganPower = $HoroscopeFortune->tianganPower();// 计算十天干气力值
            $guowang = $HoroscopeFortune->guowang();// 计算五行过旺
            $shoukeJishu = $neige['score'] * 0.1;
            // 吉受克组合 财+劫，才+比，官+伤，食+枭，印+财，杀+日干，杀+同性根，杀+禄
            // 吉神：财才官印食
            $zuhe = [
                '正财' => '劫财',
                '偏财' => '比肩',
                '正官' => '伤官',
                '正印' => '正财',
                '食神' => '偏印',
                '比肩' => '七杀',
            ];
            for ($i = 0; $i < 4; $i++)
            {
                $gan1 = $tiangan[$i];
                $zhi1 = $dizhi[$i];
                $zhi1benqi = $this->param['canggan'][$zhi1][0];
                $gan1Shishen = $this->param['shishen'][$gan1][$rigan];
                $zhi1BenqiShishen = $this->param['shishen'][$zhi1benqi][$rigan];
                // 检查七杀日干
                if ($this->param['shishen'][$gan1][$rigan] === '七杀')
                {
                    $jiShenGan = $rigan;
                    $shiKeShishenGan = $gan1;
                    // 受克基数=格局基数*10%
                    // 吉神受克减分=受克基数*施克十神旺度/受克十神旺度（气力）
                    // 如果受克吉神不只一个，累加
                    $neigeTotalScore -= $neige['score'] * 0.1 * $tianganPower[$shiKeShishenGan]['score'] / $tianganPower[$jiShenGan]['score'] * 0.5;
                }
                // 检查同柱干支
                if (isset($zuhe[$gan1Shishen]) && $zuhe[$gan1Shishen] === $zhi1BenqiShishen)
                {
                    $jiShenGan = $gan1;
                    $shiKeShishenGan = $zhi1benqi;
                    $neigeTotalScore -= $neige['score'] * 0.1 * $tianganPower[$shiKeShishenGan]['score'] / $tianganPower[$jiShenGan]['score'] * 0.5;
                } elseif (isset($zuhe[$zhi1BenqiShishen]) && $zuhe[$zhi1BenqiShishen] === $gan1Shishen)
                {
                    $jiShenGan = $zhi1benqi;
                    $shiKeShishenGan = $gan1;
                    $neigeTotalScore -= $neige['score'] * 0.1 * $tianganPower[$shiKeShishenGan]['score'] / $tianganPower[$jiShenGan]['score'] * 0.5;
                }
                for ($j = 0; $j < 4; $j++)
                {
                    $gan2 = $tiangan[$j];
                    $zhi2 = $dizhi[$j];
                    $zhi2benqi = $this->param['canggan'][$zhi2][0];
                    $gan2Shishen = $this->param['shishen'][$gan2][$rigan];
                    $zhi2BenqiShishen = $this->param['shishen'][$zhi2benqi][$rigan];
                    // 八字中出现吉神受克组合（干对干、支对支、同柱干支）
                    if ($i !== $j)
                    {
                        // 干对干
                        if (isset($zuhe[$gan1Shishen]) && $zuhe[$gan1Shishen] === $gan2Shishen)
                        {
                            $jiShenGan = $gan1;
                            $shiKeShishenGan = $gan2;
                            $neigeTotalScore -= $neige['score'] * 0.1 * $tianganPower[$shiKeShishenGan]['score'] / $tianganPower[$jiShenGan]['score'] * 0.5;
                        }
                        // 支对支
                        if (isset($zuhe[$zhi1BenqiShishen]) && $zuhe[$zhi1BenqiShishen] === $zhi2BenqiShishen)
                        {
                            $jiShenGan = $zhi1benqi;
                            $shiKeShishenGan = $zhi2benqi;
                            $neigeTotalScore -= $neige['score'] * 0.1 * $tianganPower[$shiKeShishenGan]['score'] / $tianganPower[$jiShenGan]['score'] * 0.5;
                        }
                    }
                }
            }
            // 遍历地支
            foreach ($dizhi as $k1 => $v1)
            {
                // 遍历地支
                foreach ($dizhi as $k2 => $v2)
                {
                    if ($k1 < $k2)
                    {
                        $x = 0;
                        // 冲
                        if ($this->is_liuchong($v1, $v2))
                        {
                            $x = 1;
                        } elseif ($this->is_xing($v1, $v2))
                        {
                            $x = 0.7;
                        } elseif ($this->is_liupo($v1, $v2))
                        {
                            $x = 0.5;
                        } elseif ($this->is_liuhai($v1, $v2))
                        {
                            $x = 0.7;
                        }
                        // 减分=关系指数*（3-距离）*格局基数*10%
                        $neigeTotalScore -= $x * (3 - $k2 + $k1) * $neige['score'] * 0.1 * 0.5;
                    }
                }
            }
            // 某五行过旺，且日时支（本气）、时干无克制他的五行 减分=格局基数*9%
            if ($guowang !== '')
            {
                $isShouKe = false;
                $rizhibenqiWuxing = $this->param['wuxing'][$this->param['canggan'][$dizhi[2]][0]];
                $shizhibenqiWuxing = $this->param['wuxing'][$this->param['canggan'][$dizhi[3]][0]];
                $shiganWuxing = $this->param['wuxing'][$tiangan[3]];
                $wxBeiKe = [
                    '木' => '金',
                    '火' => '水',
                    '土' => '木',
                    '金' => '火',
                    '水' => '土',
                ];
                if (in_array($wxBeiKe[$guowang], [$rizhibenqiWuxing, $shizhibenqiWuxing, $shiganWuxing], true))
                {
                    $isShouKe = true;
                }
                if ($isShouKe === false)
                {
                    $neigeTotalScore -= $neige['score'] * 0.09 * 0.5;
                }
            }
            // 设置内格保底30分
            if ($neigeTotalScore < 30)
            {
                $neigeTotalScore = 30;
            }
            /**
             * 内格
             *  95 格局富贵，万事可成
             *  80 格局平稳，节节高升
             *  60 格局跌宕，时起时落
             *  40 格局平凡，可待机缘
             *  40以下 若逢好运，别有洞天
             */
            if ($neigeTotalScore >= 95)
            {
                $tag_list = '格局富贵，万事可成';
            } elseif ($neigeTotalScore >= 80)
            {
                $tag_list = '格局平稳，节节高升';
            } elseif ($neigeTotalScore >= 60)
            {
                $tag_list = '格局跌宕，时起时落';
            } elseif ($neigeTotalScore >= 40)
            {
                $tag_list = '格局平凡，可待机缘';
            } else
            {
                $tag_list = '若逢好运，别有洞天';
            }
            $neigeConfig = config('bazi.neige');
            $res['neige'] = [
                'title' => $neigeConfig[$neige['code']]['name'],
                'content' => $neigeConfig[$neige['code']]['text'],
                'score1' => $neigeTotalScore,
                'score2' => 100,
                'tag_list' => $tag_list,
            ];
        }
        /**
         * 总分+关键词
         * 所有内外格局分相加得总分
         * 关键词
         * 总分
         *  150 世间少有，富贵天然
         *  120（如无外格，总分85以上） 格局大成，人生赢家
         *  90（如无外格，总分70以上） 中流砥柱，富贵可期
         *  60 看似平凡，时来运转
         *  60以下 人生起伏，成败皆有
         */
        $totalScore = $neigeTotalScore + $waigeTotalScore;
        if ($totalScore >= 150)
        {
            $code = 0;
            $tag = '世间少有，富贵天然';
        } elseif ($totalScore >= 120 || ($waigeTotalScore === 0 && $neigeTotalScore >= 85))
        {
            $code = 1;
            $tag = '格局大成，人生赢家';
        } elseif ($totalScore >= 90 || ($waigeTotalScore === 0 && $neigeTotalScore >= 70))
        {
            $code = 2;
            $tag = '中流砥柱，富贵可期';
        } elseif ($totalScore >= 60)
        {
            $code = 3;
            $tag = '看似平凡，时来运转';
        } else
        {
            $code = 4;
            $tag = '人生起伏，成败皆有';
        }
        $zhengtiConfig = config('bazi.zhengti');
        $res['zhengti'] = [
            'title' => '',
            'content' => $zhengtiConfig[$code]['text'],
            'score1' => $totalScore,
            'score2' => null,
            'tag_list' => $tag,
        ];
        return $res;
    }

    /**
     * 获取指定日期流日、流月、流年
     * @param int $time 指定日期时间戳
     * @param int $num 需要获取连续多少天的流日
     * @return array
     */
    public function getLiuri($time = 0, $num = 1): array
    {
        $res = [];

        $time2 = 941990400;

        $time1 = strtotime(date('Y-m-d', $time));
        // 日辰初始默认使用24点
        $val = ($time1 - $time2) / 86400 % 60;
        // 处理流日索引在0～60之间
        $dayIndex = $val < 0 ? $val + 60 : $val;
        // 六十甲子
        $chinese_era = $this->param['chinese_era'];

        $advanceInfo = [
            'year' => (int)date('Y', $time1),
            'month' => (int)date('n', $time1),
            'day' => (int)date('d', $time1),
            'hour' => (int)date('H', $time1),
            'minute' => (int)date('i', $time1),
            'timezone' => 8,
            'is_summer' => 0,
        ];

        $liunianIndex = $this->getYearStemBranche($advanceInfo['year']);

        // 获取开始时间的太阳度数
        $sunDeg = (Astrolog::getInstance())->setExecPrefix(config('astrolog.prefix'))->getPlanetOriginData('0', $advanceInfo)[0] * 1;

        // 获取连续N天的流日
        for ($i = 0; $i < $num; $i++)
        {
            if ($dayIndex === 60)
            {
                $dayIndex -= 60;
            }
            // 流日干支字符串
            $rizhuString = $chinese_era[$dayIndex];
            // 流日时间戳
            $dayTime = $time + 86400 * $i;
            // 所属月份
            $month = (int)date('n', $dayTime);
            // 流日干支数组
            $liuri = [mb_substr($rizhuString, 0, 1), mb_substr($rizhuString, 1, 1)];
            // 当前流日太阳度数
            $cSunDeg = $sunDeg + $i;
            if ($cSunDeg >= 360)
            {
                $cSunDeg = mod360($cSunDeg);
            }
            $nianIndex = $liunianIndex;
            if ($month < 3 && $cSunDeg < 315)
            {
                // 未立春显示上一年干支
                $nianIndex--;
            }
            if ($nianIndex < 0) $nianIndex = 59;
            // 流年 干支
            $liunianString = $this->param['chinese_era'][$nianIndex];
            // 流年干支数组
            $liunian = [mb_substr($liunianString, 0, 1), mb_substr($liunianString, 1, 1)];
            $liuyue = $this->getLiuyueGanzhi($liunian[0], $sunDeg);
            // 日期字符串
            $date = date('Y-m-d', $dayTime);
            $res[$date] = [
                'liuri' => $liuri,
                'liuyue' => $liuyue,
                'liunian' => $liunian,
            ];
            $dayIndex++;
        }
        return $res;
    }

    /**
     * 根据出生信息获取八字等信息
     *  农历日期：乙亥年六月二十 午时
     *  八字：年柱(乙亥) 月柱(癸水) 日柱(己酉) 时柱(庚午)
     *  喜用神：卯木
     *  格局列表：["杀用伤官","金神格，天地德合","时来运转"]
     *          ['此处为内格局','此处为外格局']，如没有格局则为空字符串，如果包含多个用中文逗号拼接
     * @retrun array
     */
    public function getUserDataForAI(): array
    {
        $bazi = $this->data['bazi'];
        // 获取八字用神信息
        $yongshen = HoroscopeFortune::getInstance()->setRecord($this->option['recode'])->baziyongshen(['good_years' => [], 'bad_years' => []]);

        $geju = $this->gejupanding($bazi);
        $neige = $geju['neige']['title'] ?? '';
        $waige = implode(',', array_column($geju['waige'], 'title'));

        $baziStr = '年柱(' . $bazi[1] . $bazi[2] . ') 月柱(' . $bazi[3] . $bazi[4] . ') 日柱(' . $bazi[5] . $bazi[6] . ') 时柱(' . $bazi[7] . $bazi[8] . ')';

        // 公历转换为农历
        $nongliData = (new Calendar())->solar($this->option['recode']['year'], $this->option['recode']['month'], $this->option['recode']['day']);
        $nongli = [
            'year' => $nongliData['lunar_year_chinese'],
            'month' => $nongliData['lunar_month_chinese'],
            'day' => $nongliData['lunar_day_chinese'],
        ];

        return [
            'chinese_calendar_date' => $bazi[1] . $bazi[2] . '年' . $nongli['month'] . $nongli['day'] . ' ' . $bazi[8] . '时',
            'bazi' => $baziStr,
            'joyful_god' => $yongshen['yongshen'],
            'pattern' => [$neige, $waige],
        ];
    }

    /**
     * 根据档案信息获取 五行比例、喜用神、格局
     * @param array $recordInfoList 档案信息数组
     * @return array
     */
    public function getUserDataForQiming($recordInfoList = []): array
    {
        $res = [];
        if (!empty($recordInfoList))
        {
            foreach ($recordInfoList as $k1 => $v1)
            {
                $HoroscopeFortuneInstance = HoroscopeFortune::getInstance()->setHoroscopeInstance($this)->setAdvance(date('Y-m-d'))->setRecord($v1);
                $bazijiedu = $HoroscopeFortuneInstance->bazijiedu();
                $yongshen = $HoroscopeFortuneInstance->baziyongshen(['good_years' => [], 'bad_years' => []]);// 获取八字用神信息
                $geju = $this->gejupanding($HoroscopeFortuneInstance->getbazi());

                $total = 0;
                $max = ['k' => -1, 'value' => 0];
                $min = ['k' => -1, 'value' => 100];
                foreach ($bazijiedu['wuxing']['list'] as $k => $item)
                {
                    $bazijiedu['wuxing']['list'][$k]['score'] = (int)$item['score'];
                    $total += $bazijiedu['wuxing']['list'][$k]['score'];

                    if ($bazijiedu['wuxing']['list'][$k]['score'] > $max['value'])
                    {
                        $max = ['k' => $k, 'value' => $bazijiedu['wuxing']['list'][$k]['score']];
                    }
                    if ($bazijiedu['wuxing']['list'][$k]['score'] < $min['value'])
                    {
                        $min = ['k' => $k, 'value' => $bazijiedu['wuxing']['list'][$k]['score']];
                    }
                }

                if ($total > 100)
                {
                    $add = $total - 100;
                    $bazijiedu['wuxing']['list'][$min['k']]['score'] += $add;
                } elseif ($total < 100)
                {
                    $add = 100 - $total;
                    $bazijiedu['wuxing']['list'][$max['k']]['score'] -= $add;
                }

                $wuxingPerc = array_column($bazijiedu['wuxing']['list'], 'score', 'name');

                $waige = array_column($geju['waige'], 'title');
                $neige = $geju['neige']['title'] ?? '';
                $gejuList = array_merge([$neige], $waige);

                $tmp = [
                    'wuxingbili' => $wuxingPerc,
                    'quming' => $yongshen['quming'],
                    'yongshen' => $yongshen['yongshen'],
                    'pattern' => $gejuList,
                ];
                $res[$k1] = $tmp;
            }
        }
        return $res;
    }
}
